不允许在子查询的同时删除原表数据(ERROR 1093 (HY000))

delete from t where userid in (select userid from t where userid < 10);

ERROR 1093 (HY000): You can't specify target table 't' for update in FROM clause


delete from t where userid in (select userid from (select userid from t where userid < 10) tmp );

Query OK, 2 rows affected (0.02 sec)




你可能感兴趣的:(mysql)