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 |
|
priyaram
Yak Posting Veteran
82 Posts |
Posted - 2007-02-09 : 09:59:43
|
| i am having table A and table B.TableA = 800 recordsTableB = 805 recordsBoth are having key relationship.I like to know the what are the 5 extra records in the TableB.How can i get the records.??Select * from TableA a, TableB bwhere a.no not like b.nono it's not retriving the differnce 5 records. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-09 : 10:03:05
|
[code]select *from TableA a left join TableB bon a.no = b.nowhere b.no is null[/code] KH |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-09 : 10:06:52
|
or using the newer EXCEPT operator:Select * from TableBEXCEPTSelect * from TableA Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-02-09 : 10:16:34
|
| Another way is to use the NOT INSELECT B.*FROM TableB BWHERE B.No NOT IN (SELECT No FROM TableA)Or use NOT EXISTSSELECT B.*FROM TableBWHERE NOT EXISTS (SELECT 'X' FROM TableA A WHERE A.No = B.No)SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
|
|
|