This is my request
> DELETE FROM A WHERE id in ( Select
> id From A Left Join B on开发者_Python百科 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
Maybe you could do it like this instead?
DELETE FROM A WHERE id NOT IN (SELECT DISTINCT B.id FROM B);
You want to delete all records from table A that don't have a matching id in table B?
How about this:
DELETE
FROM A
WHERE NOT EXISTS (select 1 from B where A.id = B.id);
DELETE FROM A
WHERE NOT EXISTS (
SELECT *
FROM B
WHERE content_id = B.content_id
)
精彩评论