Mysql Select statement using may or

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?)

Từ khóa:
digg delicious stumbleupon technorati Google live facebook Sphinn Mixx newsvine reddit yahoomyweb