I need to compare a list values with a db column.
Example : list ='12,5,6,8' and I need to know which of these values doesnt exist in db column values. How would I do that?
something like this should work
<cfloop list="#yourlist#" index = "listitem">
select #listitem# list_item
select 0 list_item
where 1 = 2
) temp left join from yourtable on list_item = somefield
where somefield is null
I need this with pure sql ... How will i do that?
If you are going to use a cfquery, what I gave you should work. If you are writing a stored procedure, the logic stays the same but the syntax for the loop changes.
This works on MySQL:
FROM (select 12 dbCol union select 5 dbCol2 union select 6 dbCol3 union select 8 dbCol4) someTBLAlias
WHERE dbCol NOT IN (SELECT dbCol FROM dbTBL)