?
Solved

mysql update record question

Posted on 2011-04-27
3
Medium Priority
?
381 Views
Last Modified: 2012-05-11
I need to update about 150 records in a mysql table which are all telephone number.  Rather than type the following line 150 times for each identifier  does anyone know of a better way of doing this?  

UPDATE inventory SET supplierId = 4 WHERE identifier = '2225551001';
UPDATE inventory SET supplierId = 4 WHERE identifier = '2225551002;
UPDATE inventory SET supplierId = 4 WHERE identifier = '2225551003';
UPDATE inventory SET supplierId = 4 WHERE identifier = '2225551004';
etc.....
0
Comment
Question by:ipconfig610
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
darren-w- earned 2000 total points
ID: 35475352
UPDATE inventory SET supplierId = 4 WHERE identifier IN ('2225551001','2225551002'....)
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35475366
or
UPDATE inventory SET supplierId = 4
WHERE identifier between 2225551001 and 2225551004
0
 
LVL 41

Expert Comment

by:ralmada
ID: 35475587
Another possibility is to have those 150 telephone numbers in a separate table and then do a join update something like

update inventory a, tablewithphones b
set a.supplierid = 4
where a.identifier = b.phonenumber
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question