mysql delete from 限制

mysql进行delete时若子查询中的表为同一张表会出现错误
如:
mysql> DELETE FROM tab1 WHERE col1 = ( SELECT MAX( col1 ) FROM tab1 );
ERROR 1093 (HY000): You can’t specify target table ‘tab1′ for update in FROM clause
我们可以用别名来绕过这个限制
mysql>DELETE FROM tab1 where col1 = (select * from (select id   from tab1) as b)

你可能感兴趣的:(mysql,限制,开发技术)