连表查询后进行update|delete操作,会报错
sql:
delete from feed where id in (
select f.id from comment as c, feed as f where f.column1 =c.id
);
会报错:
You can't specify target table 'feed' for update in FROM clause
只要修改成:
delete from feed where id in (
select a.id from (
select f.id from comment as c, feed as f where f.column1 =c.id
) a
);
也就是说将select出的结果再通过中间表select一遍,就可以了。