Any*_*are 2 sql t-sql informix
我想选择存在于特定表中但不存在于另一个表中的所有行以删除它们.
我写下面的查询,但我得到两个表中的行!!
SELECT UNIQUE b.values_key FROM request_fo a INNER JOIN rm_trans b
ON b.values_key != a.req_year || ',' || a.req_ser
AND b.taskcode = 19
AND b.values_key IS NOT NULL
AND a.req_year IS NOT NULL
AND a.req_ser IS NOT NULL
Run Code Online (Sandbox Code Playgroud)
我想使用以下内容删除存在的数据request_fo
而不存在于rm_trans
:
DELETE request_fo
FROM request_fo a
INNER JOIN
rm_trans b
ON b.values_key != a.req_year || ',' || a.req_ser
AND b.taskcode = 19
AND b.values_key IS NOT NULL
AND a.req_year IS NOT NULL
AND a.req_ser IS NOT NULL
Run Code Online (Sandbox Code Playgroud)
这是正确的吗 ??
如果您不能使用连接语法,也可以使用子选择.
delete from t1
where t1 = something
and not exists
(
select 1
from t2
where t1.key = t2.key
)
Run Code Online (Sandbox Code Playgroud)