我想用如下语句删除查询结果,但是报错
错误如下:#1093 - You can't specify target table 'jo_sourcedata' for update in FROM clausedelete from sourcedata where exists(select * from sourcedata js where js.item_type=2 and not exists (select * from person jp where jp.per_id = js.item_id ))
我又想到用,如下的语句,但是也出现语法错误delete from sourcedata where id in (select js.id from sourcedata js where js.item_type=2 and not exists (select * from person jp where jp.per_id = js.item_id)
请帮忙看看用什么语句才能删除查询出来的结果,查询出来的结果有(10万多条),我想在phpmyadmin的sql里运行。谢谢。
错误如下:#1093 - You can't specify target table 'jo_sourcedata' for update in FROM clausedelete from sourcedata where exists(select * from sourcedata js where js.item_type=2 and not exists (select * from person jp where jp.per_id = js.item_id ))
我又想到用,如下的语句,但是也出现语法错误delete from sourcedata where id in (select js.id from sourcedata js where js.item_type=2 and not exists (select * from person jp where jp.per_id = js.item_id)
请帮忙看看用什么语句才能删除查询出来的结果,查询出来的结果有(10万多条),我想在phpmyadmin的sql里运行。谢谢。
有两张表:a ,b
a 与 b通过 a.id ,b.aid 关联
现在b表中存在很多多余的信息,a表没有b表的数据,于时通过如下查询出来了select * from b where b.item_type=2 and not exists (select * from a where a.id = b.aid )
现在我想继续操作,删除查询出的数据,该如何操作啊。谢谢。。不知道描述的清楚吗?
出现的错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* from sourcedata js where js.item_type=2 and not exists (select 1 from pe' at line 1
1、保存查询结果到临时表
2、关联临时表进行删除phpmyadmin 可以一次执行多条指令
php 代码中也只需执行2次 mysql_query不能连在一起写的原因是:你的删除条件是与可能被删除的记录相关联的结果集,一旦其中某条记录被删除了,整个结果集就无效了,必须重新产生。虽然理论上可以实现,但实际上行不通
试想一下删除一万条记录的同时要做一万次查询,是个什么局面