How to block table to booking? My booking table has from_datetime and to_datetime fields. I would like to avoid situation, when two users book something in the same time.
My attempts:
TERMINAL 1: - user1
LOCK TABLE booking READ;
INSERT INTO booking VALUES ('2019-01-01 12:00:00', '2019-01-01 14:00:00');
Now table booking should be locked, and other users should not be able to read from its, but...
TERMINAL 2: - user2
SELECT * from booking
I have results... Why? This should be blocked until I do in TERMINAL 1:
unlock tables;