我试图将NOT IN查询转换为NOT EXISTS。但是,不存在并不能回报我的期望......我做错了什么?
不在查询中:
SELECT BLC.LABEL_COLECCTIONS_ID
FROM BET_LABELS BL,
BET_LABEL_SEASONS BLS,
BET_LABEL_COLLECTIONS BLC
WHERE BLC.LABEL_ID = BL.LABEL_ID
AND BL.LABEL_ID = BLS.LABEL_ID
AND BLC.COLLECTION_ID = 6470
AND BLS.SEASON_ID = 71
AND NOT EXISTS (
SELECT GP.LABEL_COLECCTIONS_ID
FROM GPE_PRICES GP,
GPE_COLLECTION_ASSIGNEMENTS GCA
WHERE GP.COLLECTION_ASSIGNEMENT_ID = GCA.COLLECTION_ASSIGNEMENT_ID
AND GCA.COLLECTION_ASSIGNEMENT_ID = 101591665
AND GCA.SEASON_ID = 71
);
不存在:
{{1}}
任何建议将不胜感激。
答案 0 :(得分:4)
您需要在条件
中包含LABEL_COLECCTIONS_IDSELECT BLC.LABEL_COLECCTIONS_ID
FROM BET_LABELS BL,
BET_LABEL_SEASONS BLS,
BET_LABEL_COLLECTIONS BLC
WHERE BLC.LABEL_ID = BL.LABEL_ID
AND BL.LABEL_ID = BLS.LABEL_ID
AND BLC.COLLECTION_ID = 6470
AND BLS.SEASON_ID = 71
AND NOT EXISTS (
SELECT *
FROM GPE_PRICES GP,
GPE_COLLECTION_ASSIGNEMENTS GCA
WHERE GP.COLLECTION_ASSIGNEMENT_ID = GCA.COLLECTION_ASSIGNEMENT_ID
AND GCA.COLLECTION_ASSIGNEMENT_ID = 101591665
AND GCA.SEASON_ID = 71
and GP.LABEL_COLECCTIONS_ID=blc.label_colecctions_id
);