Reverse IN query
Reverse IN query
(OP)
Table definition
tblFoo
x varchar
tblFoo
------
x
------
abc
def
ghi
I have a string like 'abc,def,ghi,jkl'
and I want to say return for me everything in
this string that is not in tblFoo. So basically
the reverse of:
SELECT *
FROM tblFOO
WHERE x NOT IN ('abc,def,ghi,jkl');
Ultimately I would be looking for the result to say jkl in this instance as it is in my string but not in tblFoo.
Thanks in advance for replies.
tblFoo
x varchar
tblFoo
------
x
------
abc
def
ghi
I have a string like 'abc,def,ghi,jkl'
and I want to say return for me everything in
this string that is not in tblFoo. So basically
the reverse of:
SELECT *
FROM tblFOO
WHERE x NOT IN ('abc,def,ghi,jkl');
Ultimately I would be looking for the result to say jkl in this instance as it is in my string but not in tblFoo.
Thanks in advance for replies.
RE: Reverse IN query
If your string is 'abc, def, ghi, jkl', then your logic would form a table having abc, def, ghi, jkl as values. Let's call this temp_table with 'y' as a column.
After you have this table you can do:
select * from temp_table where y not in (select x from tblFoo)
RE: Reverse IN query
you'd be better off re-posting this question in the forum for your particular database system
for example, in MySQL you can say
... WHERE FIND_IN_SET(x,'abc,def,ghi,jkl') = 0
but FIND_IN_SET works ~only~ in MySQL
r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
RE: Reverse IN query
Thanks for replies