Reputation: 45
Can somebody refresh my memory on how to build a query for this.
I want to use a list of several names (first and last), to update their rows in the table with same information. for example:
if I have a table set up with the columns: [first_name],[last_name],[dob],[married_status]
I want to find:
(bob, smith), (robert, john), (jane, doe);
and edit their field for [married_status] to 'm'.
how do I structure this search and replace?
Thanks!
Upvotes: 1
Views: 41
Reputation: 106
Code:
UPDATE tablename
SET married_status = 'm'
WHERE
( first_name = 'bob' AND last_name = 'smith' )
OR
( first_name = 'robert' AND last_name = 'john' )
OR
( first_name = 'jane' AND last_name = 'doe' )
Upvotes: 1
Reputation: 71424
You would use UPDATE
query:
UPDATE `table`
SET `married_status` = 'm'
WHERE
(`first_name` = 'bob' AND `last_name` = 'smith')
OR (`first_name` = 'robert' AND `last_name` = 'john')
OR (`first_name` = 'jane' AND `last_name` = 'doe')
Upvotes: 0