表大师
| id | user |
| 1 | user1 |
| 3 | user2 |
| 4 | user3 |
table ver
| id_v | value |
| 2 | value1 |
| 3 | value2 |
我必须删除表ver
上的id_v 2我'有这个查询
DELETE FROM `ver` WHERE id_v in (SELECT v.id_v
FROM master m
RIGHT JOIN ver v
ON m.id = v.id_v
WHERE m.id IS NULL)
但这是错误
You can't specify target table 'ver' for update in FROM clause
答案 0 :(得分:1)
试试这个
DELETE FROM `ver` WHERE id_v in ( SELECT id_v from
(SELECT v.id_v FROM master m
RIGHT JOIN ver v
ON m.id = v.id_v
WHERE m.id IS NULL) as temp )
答案 1 :(得分:1)
答案 2 :(得分:0)
您不能使用table ver的子查询从表ver本身中删除某些内容。
你是说这个?
delete from ver where id_v is null;