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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select query with where inselect condition

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-08-11 : 16:16:06
I am trying to use the following query, i am using another inselect query not in under where condition, it is not working.

the inv_id's are not in this table: Tab_COSTPayments, still i don't see the rows appearing as results.


Select inv_id,inv_no from Tab_COSTInvoice where ContractID=159 and Deleted = '0' and
inv_id NOT IN (SELECT inv_id FROM Tab_COSTPayments)

Thank you very much for the helpful info.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-08-11 : 16:51:35
My guess is
SELECT inv_id FROM Tab_COSTPayments
returns some NULLS.

Try running the query changing this to
SELECT inv_id FROM Tab_COSTPayments WHERE inv_id IS NOT NULL

Or
set ansi_nulls off
before executing the query.
Go to Top of Page
   

- Advertisement -