I am using the following query to get zero results on Amazon Redshift.
Query 1:
SELECT id
FROM flx2.groups
WHERE id NOT IN (SELECT groupid FROM flx2.lmsprovidergroups)
Now, the same query starts to give me results if I modify it slightly to:
Query 2:
SELECT id
FROM flx2.groups
WHERE id NOT IN (SELECT id
FROM flx2.groups
WHERE id IN (SELECT groupid FROM flx2.lmsprovidergroups))
I'm trying to exclude the id
from lmsprovidergroups
to get a subset from groups
. Why would I have to include it first (as in the inner query in query 2) and then exclude it again?
As far as I'm concerned, query 1 is absolutely the same as query 2.
Why does query 2 work while query 1 does not?