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 |
|
srussell
Starting Member
9 Posts |
Posted - 2008-08-07 : 13:54:05
|
| I have two tables that store a list of addresses for a user. I need to compare all the address entries in one table to the other for that user and then return any row that is different. Does anyone have an idea on how to do this? |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-08-07 : 14:01:30
|
| [code]select * from mytable1 a Full outer join mytable2 bon a.Address1 = b.Address1and a.Address2 = b.Address2and a.City = b.Cityand a.Zip = b.Zipand a.State = b.statewherea.Address1 is nullor b.Address1 is null[/code] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-07 : 14:02:05
|
| [code]SELECT t1.addressFROM Table1 t1LEFT JOIN Table2 t2ON t2.address=t1.addressWHERE t2.address IS NULLUNION ALLSELECT t2.addressFROM Table2 t2LEFT JOIN Table2 t2ON t2.address=t1.addressWHERE t2.address IS NULL[/code] |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-08-07 : 14:43:35
|
| Not Sure though:( It returns distinct rows)Select address 1,address 2 from table aexceptselect address 1, address2 from table b |
 |
|
|
srussell
Starting Member
9 Posts |
Posted - 2008-09-25 : 10:07:36
|
| This is what I am trying and it is just returning all the records from table one with that id number. Any help would be great.select * from table1 as m where not exists (select * from table2 where memNum = m.memNum and memName = m.memName and memAdd1 = m.memAdd1 and memAdd2 = m.memAdd2 and memCity = m.memCity and memState = m.memState and memZip5 = m.memZip5 and memZip4 = m.memZip4 and id= '1') and id= '1' |
 |
|
|
|
|
|