I've 2 tables.
First with Id and Name: like TAB_FIRST.first_id as INT and TAB_FIRST.first_name as VARCHAR.
The second table as unique ID, name and (that's the key...) a VARCHAR field with a list of Id from the first table. So this field contain data like "26,27,29,28,25,35"
I want to get data from the first table, which Ids are not in the list of If of the second one.
If I perform:
SELECT
first_id,
first_name
FROM TAB_FIRST
WHERE first_id NOT IN (26,27,29,28,25,35)
I works. If I use NOT IN ('26','27','29','28','25','35') it works too.
But when I remplace the hard coded list by a select, the NOT IN don't filter the data and I get all data from first table. So:
SELECT
first_id,
first_name
FROM TAB_FIRST
WHERE first_id NOT IN (SELECT second_list_id FROM TAB_SECOND)
doesn't work.
I'm pretty sure this came from the fact I try to perform the NOT IN between an INT (first_id) and a list which is a "string". I tried to CAT/CONVERT first_id, try to perform a LOCATE on the list adding '' and so on. Each time same result. Is there a way to do that (without using a third table to link id from first table with id from second one).
Thanks a lot