|
I have two table(T1,T2) in my database,in those table column 'ID' is common.The problem is that when I inter join them,I can't find those ID that are not match.How I can find those ID that are not common in two table.
(comments are locked)
|
|
With SQL Server 2012 you can use the EXCEPT keyword I believe that EXCEPT is available in SQL Server 2005 and higher, just as an FYI.
Oct 17 '12 at 03:41 PM
JohnM
was it indeed? Why on earth didnt I use it more often then?!
Oct 17 '12 at 03:42 PM
Fatherjack ♦♦
Yup, I believe so! http://msdn.microsoft.com/en-us/library/ms188055(v=sql.90).aspx ;-) Unless of course I'm reading that wrong . .which is entirely possible. :D
Oct 17 '12 at 03:47 PM
JohnM
Oh, I'm quite prepared to believe it.
Oct 17 '12 at 03:50 PM
Fatherjack ♦♦
(comments are locked)
|
|
To find the records in T1 that are not in T2 you can LEFT JOIN T1 to T2 and limit to where there is a NULL in the ID column of T2. Is that what you're trying to do?
(comments are locked)
|
|
If you need the intersection, use the INNER join. If you need the records which are in left side table and not in right side table which we can say disjunction, use the LEFT join and put the condition RIGHT TABLE.ID IS NULL in where clause. This way you can read the record which are in left side table bit not in right side table.
(comments are locked)
|

