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.
Author |
Topic |
Benny_57
Starting Member
2 Posts |
Posted - 2013-07-23 : 06:30:57
|
Hi!I have 2 tables.Both tables containes a field called itemnoThese 2 tables should containe the same amount of rows, but are not.Tabel 1 containes 791 and tabel 2 contains 736.How do i write a query to get the answer witch itemno missing in table 2? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-23 : 06:33:33
|
There are a few different ways to write the query. One way is as follows:SELECT itemno from Table1 EXCEPT SELECT itemno from Table2;SELECT itemno from Table2 EXCEPT SELECT itemno from Table1; The first gives you a list of itemno's in table1 that are not in table2. Second one gives the opposite. |
|
|
Benny_57
Starting Member
2 Posts |
Posted - 2013-07-23 : 06:37:52
|
Thank's for the quick replay James K |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-23 : 07:32:02
|
just FYINOT EXISTS,LEFT JOIN, NOT IN can also be used for same scenario------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|