Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 How can a list of values be checked for non-existance in a table?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-12-24 : 10:14:52
Dave writes "I have a list of values, and want to return a list of those values that are not present in a table. I've tried the following in DB/2:

This works:

select t1.* from (values 1,2,3,4) as t1

but extending it to:

select t1.* from (values 1,2,3,4) as t1 where not exists \
(select 'x' from idtable t2 where t2.id = t1.*)

doesn't work because there doesn't seem to be any way to referto a column name for the values list (t1.* is just a non-functional placeholder in the sub-select.) I haven't been able to find a way to assign a correlation name to the column returned by the values.

There are other options such as creating temporary tables (three extra steps to create, load and drop), or checking one value at a time, but this seems so close that I hate to give up on it.

-Dave"
   

- Advertisement -