I have two MySql tables tableA and tableB, primary key "id" in tableA is used as a foreign key "parent_id" in tableB. I would like to update single row in tableB using select...for update so that other users can not access it while transaction is not over. My question is - how to correctly update selected row in one query? Here is my sample code:
START TRANSACTION;
SELECT b.reserved, b.owner FROM tableB b, tableA a
WHERE b.parent_id = a.id AND a.guid ='5344a990-fedf-4deb-a114-0d5d6a3ba180' FOR UPDATE;
UPDATE tableB SET...;
COMMIT;
Thank you!