Search code examples
mysqlsqlsql-deletemysql-error-1093

You can't specify target table 'A' for update in FROM clause


This is my request

> DELETE FROM A WHERE id in (    Select
> id From A    Left Join B on A.id=B.id 
> Where B.id is null )

When I execute this I have this error

You can't specify target table 'A' for update in FROM clause


Solution

  • Maybe you could do it like this instead?

    DELETE FROM A WHERE id NOT IN (SELECT DISTINCT B.id FROM B);