【问题标题】:MySQL error 1093. how to delete from thisMySQL 错误 1093。如何从中删除
【发布时间】:2015-07-23 01:28:15
【问题描述】:

选择工作:

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。您不能在 FROM 子句 0,001 秒中指定目标表 'pre_log' 进行更新

【问题讨论】:

    标签: mysql sql


    【解决方案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
        )
    

    【讨论】:

      猜你喜欢
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 2011-05-27
      • 2014-06-24
      • 2014-01-26
      • 2018-04-20
      • 1970-01-01
      相关资源
      最近更新 更多