日期:2014-05-17 浏览次数:20476 次
SELEC * FROM tborder a WHERE not exists(
SELECT top(1)1 from tbitem b where a.order_id=b.order_id
)
DELETE FROM tborder a WHERE not exists(
SELECT top(1)1 from tbitem b where a.order_id=b.order_id
)
--查询
SELECT *
FROM tborder
WHERE order_id not in (SELECT order_id FROM tbitem)
--删除
DELETE FROM tborder
WHERE order_id not in (SELECT order_id FROM tbitem)
或者:
SELECT *
FROM tborder a
WHERE not exists(SELECT 1 FROM tbitem b where a.order_id=b.order_id)
DELETE FROM tborder a
WHERE not exists(SELECT 1 FROM tbitem b where a.order_id=b.order_id)