表大师
| id | user |
| 1 | user1 |
| 3 | user2 |
| 4 | user3 |
表版
| 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
最佳答案
可以使用以下方法完成
delete
v
from ver v
left join master m on m.id = v.id_v
where m.id is null
Demo
关于mysql - SQL选择联接和一起删除,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26955639/