我想使用内部和外部select语句筛选我的游标中的记录。 我该如何做到这一点?用于select的SQL中的子查询
我只想要'_02'记录从这两个表。
table A:
col1
1122_01
1234_02
3456_02
7899_02
table B:
col1
1111_02
1234_02
4567_02
table Final:
col1
3456_02
7899_02
SELECT distinct a.col1
FROM A a
WHERE NOT EXISTS (SELECT 1 FROM B b
WHERE b.col1 = a.col1
and b.col1='02')
and a.col1='02'
这项工作?
或者这个?
SELECT distinct t.item, t.skuloc loc
FROM SCPOMGR.UDT_DFUTOSKUMAP t
, SCPOMGR.udt_gen_param G
WHERE NOT EXISTS (SELECT *
FROM SCPOMGR.SKU s1
, SCPOMGR.udt_gen_param G
,SCPOMGR.UDT_DFUTOSKUMAP t
WHERE s1.ITEM = t.ITEM
AND s1.LOC = t.SKULOC
and G.region='XYZ'
and G.jda_code= substr(s1.loc,-2,2)
)
and G.region='XYZ'
and G.jda_code= substr(T.SKUloc,-2,2)
你的例子对我没有意义 –
光标?我看不到游标。 –
@ P.Salmon我在游标中使用 –