I am trying to write a SQL statement that will update a field for records in a table that match certain conditions. I am mostly there but it is updating every record in the table rather than just the 33 that match the condition. This is what I have:
SET accepted = 'true'
FROM invitations i
INNER JOIN users u ON i.parent_email=u.email
WHERE u.encrypted_password <> ''
You can try this :)
UPDATE invitations SET accepted = 'true' WHERE ( SELECT encrypted_password FROM users WHERE invitations.parent_email=users.email ) <> '' AND invitations.accepted='false'