PDA

View Full Version : UPDATE all in list using or (||)


fuzzy1
09-28-2006, 09:04 PM
I thought this would work, but it only updates record for first name in list.:(

UPDATE `contacts`
SET invalid_email =1
WHERE full_name = "Pepper Abbott" || "Neil Adam" || (many many more) Is something like this possible???

fuzzy1
09-28-2006, 09:10 PM
Okay, Never mind:o
Inelegant but, this worked

UPDATE contacts
SET invalid_email =1
WHERE full_name = "Neil Adam" OR full_name = "Claudia Aglar" OR full_name = "Akintola Akinyemi" OR full_name = "Arthur Alarcon" OR full_name = "Robert Allen" OR full_name = "Jesus Alonzo":D

Fumigator
09-28-2006, 10:32 PM
You can also use the IN keyword:

SELECT fields
FROM table
WHERE lastname in("stevens", "white", "smith")


This syntax makes it easier to replace hard-coded names with an array of values (from PHP for example).