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
 General SQL Server Forums
 New to SQL Server Programming
 Filter

Author  Topic 

satheesh
Posting Yak Master

152 Posts

Posted - 2011-04-20 : 09:51:35
Dear All,

I need to retrive all data from cst table where cst.transid not in filter.cstid or filter.quoteid

ie.this 'transid' field contain both cstid and quoteid(mixed).So i need to find the unique data from cst table by eliminating existing cstid and quoteid using filter table

there is no other common field to make join.How to filter this.Any help would be highly appreciated.

Regards,
SG

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-20 : 09:56:13
SELECT * FROM cst c
WHERE NOT EXISTS(SELECT * FROM filter WHERE cstid=c.transID OR quoteid=c.transid)
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-20 : 09:57:14
select *
from cst
where transid not in (select cstid from filter)
and transid not in (select quoteid from filter)


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -