How to do it in mysql: If id = idold THEN UPDATE status = 1
1 answer
UPDATE users u
SET status = 1
WHERE EXISTS (SELECT id FROM usersold WHERE id = u.id)
Alternative version:
UPDATE users
SET status = 1
WHERE id IN (SELECT id FROM usersold)
You should test, and depending on your database, you may find it performs better than another, although I expect any decent database to be optimized to be the same anyway.
+5
source to share