Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

i was working on sql server 2008.

where i was comparing a column from one to another table,
which is not equal to one another.

n

my query, what i tried so far, is:

SELECT COUNT(i.ITMRQ) as vCount FROM tbl_itmrq i
inner join tbl_po p on p.Itmrq != i.ITMRQ


plz let me know, whether this one is correct or not.

thanks
Posted

1 solution

use not exists instead:
SQL
SELECT COUNT(i.ITMRQ) as vCount FROM tbl_itmrq i
WHERE NOT EXISTS
(SELECT * FROM tbl_po p WHERE p.Itmrq = i.ITMRQ)

refer: sql-exists[^]
 
Share this answer
 
v2
Comments
Maciej Los 10-Apr-14 17:50pm    
+5!
Peter Leow 12-Apr-14 7:39am    
Thank you, Maciej.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900