如何鎖定空行?MYSQL - 鎖空行
我要鎖定一個空的選擇,例如:
會議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>
會議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>
我需要第二節等到會議1的結果前完成返回。
我該如何做到這一點?
謝謝?
謝謝,這應該工作。當有行時,沒有像FOR UPDATE這樣的方法? – keepwalking 2011-06-15 21:45:12
當你確實有行時,'for update'工作。當你不這樣做的時候,你需要鎖定一個謂詞,而且我唯一的意思就是在MySQL中這樣做,這是諮詢鎖。 – 2011-06-16 09:21:29