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 |
jfm
Posting Yak Master
145 Posts |
Posted - 2013-04-23 : 11:08:55
|
Hi there, Im trying to extract the info that is not matching from two different tables: Each table has 15 columns, in which they have a common ID_Col. I need to extract all data from Table2 if the ID_Col doesn't match with Id_Col from table1. By using this query: SELECT Table1.Id_Col, Date FROM Table1LEFT OUTER JOIN Table2ON Table2.Id = Table1.IdGROUP BY Table1.Id_Col, DateI have all the info and NULL values if they are not matching.. instead of NULL values I will need the info. Any tip? Thanks |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-04-23 : 11:36:58
|
Can you show us table descriptions, some data and expected output |
|
|
jfm
Posting Yak Master
145 Posts |
Posted - 2013-04-23 : 11:42:07
|
Sure: Table_F Col_Name, Col_Place, Col_Zip, Col_Car, Col_House, Col_IdTable_SCol_Name, Col_Date, Col_End, Col_Car, Col_Mind, Col_IdExtraction: All the info from Table_S if the Col_id is not matching Col_Id from Table_FThis way I will short out all the clients that i miss in Table_F but they are in Table_SThank you |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-23 : 12:49:50
|
multiple ways1.SELECT *FROM Table_S sWHERE NOT EXISTS (SELECT 1 FROM Table_F WHERE Col_Id = s.Col_Id)2.SELECT s.*FROM Table_S sWHERE Col_Id NOT IN (SELECT Col_Id FROM Table_F)3. SELECT s.*FROM Table_S sLEFT JOIN Table_F fON f.Col_Id = s.Col_IdWHERE f.Col_Id IS NULL ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|