MySQL错误1093.如何从中删除

时间:2015-05-12 09:07:58

标签: mysql sql

选择工作:

select * from A
where A.id not in 
(
select id from A as a
inner join B as b
where (a.`name` = b.`name`
   and a.`status` = b.`description`))

删除无效:

delete from pre_log 
where pre_log.id not in 
(
select id from pre_log as p
inner join sobg_table as s
where (p.`name` = s.`name`
   and p.`status` = s.`description`)
)
  

错误代码:1093。您无法指定目标表' pre_log'在FROM子句0,001秒更新

1 个答案:

答案 0 :(得分:1)

您在子查询中指定了 pre_log 表,实际上是从中删除记录

试试这可能对你有帮助..

delete l.* from pre_log l
where l.id not in 
(
select id from 
   (
   select id from pre_log as p   
    inner join sobg_table as s
    where (p.`name` = s.`name`
       and p.`status` = s.`description`)
    ) x
    )