Mysql Select statement using may or
22-01-2010 |
|
0 phản hồi »
Question:
I have to update my mysql db. I have to update a field if it matches 1 of 184 zipcodes. I have a list of zipcodes but dont have any idea of how to created the statment.
UPDATE `cart`.`cart_cust` SET `s_county` = ‘2′ WHERE (zipcode could be one of 184)
Solution:
UPDATE `cart`.`cart_cust` SET `s_county` = ‘2′ WHERE zipcode in (zipcode list)
if your zipcode list is another table then
UPDATE `cart`.`cart_cust` SET `s_county` = ‘2′ WHERE zipcode in (select distinct zipcode from zipcodelist)
or if you are coding the values is like the following
UPDATE `cart`.`cart_cust` SET `s_county` = ‘2′ WHERE zipcode in (‘92154′,’92123′,’91911′ etc get the idea?)

















Phản hồi (0)
Trackbacks - Pingbacks (0)