1. Shared Lock (S)
A shared lock allows other sessions to read the row but prevents them from writing to it. This is useful when you want to protect data from changes while reading.
Syntax:
SELECT * FROM products WHERE id = 5 LOCK IN SHARE MODE;
Example:
START TRANSACTION;
SELECT * FROM products WHERE id = 5 LOCK IN SHARE MODE;
COMMIT;