Web Analytics Made Easy -
StatCounter UPDATE all in list using or (||) - CodingForum

Announcement

Collapse
No announcement yet.

UPDATE all in list using or (||)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • UPDATE all in list using or (||)

    I thought this would work, but it only updates record for first name in list.

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

  • #2
    Okay, Never mind
    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"

    Comment


    • #3
      You can also use the IN keyword:
      Code:
      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).

      Comment

      Working...
      X