开始了:
mysql> LOCK TABLES radcheck WRITE;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM radcheck WHERE id NOT IN (
-> SELECT id FROM (
-> SELECT id FROM radcheck WHERE attribute = 'Password' GROUP BY UserName HAVING COUNT(*) > 1
-> ) AS c
-> );
ERROR 1100 (HY000): Table 'radcheck' was not locked with LOCK TABLES
怎么回事?
编辑
SET AUTOCOMMIT = 0
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> LOCK TABLES radcheck WRITE;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM radcheck WHERE id NOT IN ( SELECT id FROM radcheck WHERE attribute = 'Password' GROUP BY UserName HAVING COUNT(*) > 1 );
ERROR 1100 (HY000): Table 'radcheck' was not locked with LOCK TABLES
mysql> LOCK TABLES radcheck READ;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM radcheck WHERE id NOT IN ( SELECT id FROM radcheck WHERE attribute = 'Password' GROUP BY UserName HAVING COUNT(*) > 1 );
ERROR 1100 (HY000): Table 'radcheck' was not locked with LOCK TABLES
pd:如果我不锁定表,查询工作正常。pd:这只是简化问题的一个例子……在现实生活中是一个删除……