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 |
|
amitbarkai
Starting Member
19 Posts |
Posted - 2010-06-23 : 03:20:21
|
| Hey Alli have a simple questionlet say my table looks like thisPersons ID FName LName SpouseID60870335 aaa bbb 0023544802547855 sda eee NULL00235448 vvv bbb 00235448as you can see person with ID 60870335 is married to 00235448 what i would like to do is get the married cupples onesmeaning ID Fname LName ID FName LName 00235448 aaa bbb 00235448 vvv bbb |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-23 : 03:33:20
|
[code]select p.ID, p.Fname, p.LName, p.SpauseID, s.FName, s.LNamefrom Person p inner join Person s on p.SpauseID = s.IDwhere p.SpauseID is not nulland p.ID <> p.SpauseID[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
amitbarkai
Starting Member
19 Posts |
Posted - 2010-06-23 : 03:51:50
|
| you anser will replay 2 rows ID Fname LName ID FName LName 60870335 aaa bbb 00235448 vvv bbb00235448 vvv bbb 60870335 aaa bbbi want to remove these duplication |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-23 : 04:27:11
|
quote: Originally posted by amitbarkai you anser will replay 2 rows ID Fname LName ID FName LName 60870335 aaa bbb 00235448 vvv bbb00235448 vvv bbb 60870335 aaa bbbi want to remove these duplication
not with the sample data that you posted in your first post. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
amitbarkai
Starting Member
19 Posts |
Posted - 2010-06-23 : 04:40:41
|
| okis there a way to return only one row ? |
 |
|
|
|
|
|