Skip to content
Advertisement

MySQL error 1093. how to delete from this

Select worked:

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 doesn’t work:

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`)
)

Error Code: 1093. You can’t specify target table ‘pre_log’ for update in FROM clause 0,001 sec

Advertisement

Answer

You have specified pre_log table in your sub query from which you actually Delete the records

try this might help you..

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
    )
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement