I have a batch of queries like this:
START TRANSACTION
SELECT amount FROM piggybank WHERE id = 2
UPDATE piggybank SET amount = amount + 5 WHERE id = 1
COMMIT
using a select ... for update
query inside the transaction should give you the semantics you want - other updates will be locked, and other sessions attempting to take this same lock will block until you commit:
START TRANSACTION
SELECT * FROM piggybank WHERE id IN (1, 2) FOR UPDATE;
SELECT amount FROM piggybank WHERE id = 2;
UPDATE piggybank SET amount = amount + 5 WHERE id = 1;
COMMIT