How can i lock empty rows?
I want to lock an empty select for example:
Session 1
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from users where username = 'nousername' for update;
Empty set (0.01 sec)
mysql>
Session 2
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from users where username = 'nousername' for update;
Empty set (0.00 sec)
mysql>
I need Session 2 to wait until session 1 is completed before the result is returned.
How can i achieve that?
Thanks?
Use an advisory lock.