我需要删除此查询中的结果:
SELECT a.cad_id
FROM `Cad` a
WHERE NOT EXISTS
(
SELECT b.cad_id
FROM `rel` b
WHERE a.cad_id = b.rel
)
我试试:
DELETE FROM `Cad` WHERE cad_id = (
SELECT a.cad_id
FROM `Cad` a
WHERE NOT EXISTS
(
SELECT b.cad_id
FROM `rel` b
WHERE a.cad_id = b.rel
)
)
我该如何解决?
答案 0 :(得分:0)
在临时表中选择内部查询数据。
DELETE FROM `cad`
WHERE cad_id IN (SELECT *
FROM (SELECT a.cad_id
FROM `cad` a
WHERE NOT EXISTS (SELECT b.cad_id
FROM `rel` b
WHERE a.cad_id = b.rel)) AS
tempTable)