我想使用此查询从表中删除具有相同记录组合的记录.该语法适用于PostgreSQL,但不适用于SQL Server.可能是什么原因?
DELETE FROM Table_stg
WHERE (cid , t_date , i_location , item ) in
(SELECT b.cid , b.t_date, b.i_location, b.itemFROM Table_vw b)
Run Code Online (Sandbox Code Playgroud)
在SQL Server(或任何其他数据库)中,您可以使用exists:
DELETE FROM Table_stg a
WHERE EXISTS (SELECT 1
FROM Table_vw b
WHERE a.cid = b.cid AND a.t_date = b.t_date AND
a.i_location = b.location AND a.item = b.item
);
Run Code Online (Sandbox Code Playgroud)
SQL Server不允许使用元组IN.