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 |
kofseattle
Starting Member
8 Posts |
Posted - 2014-03-24 : 11:39:15
|
0down votefavorite I hope I can explain this properly, it is a little confusing. I need to query for records that have the same "origin" and the same "destination". My rows will each have an origin and a destination. I need to see all those in which both match. So for instance, if there is a row with Seattle (origin) and Portland (destination) I need to see all other records with Seattle as the origin and Portland as the destination. Additionally, I need to see all records with this type of a match. So if there are records with the same origin and the same destination (not just seattle and Portland), they would also be displayed. Make sense? can you help? |
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2014-03-24 : 12:12:36
|
How many tables are you querying?Select t1.origin, t1.destinationFrom yourtable t1Where t1.origin = t1.destinationSelect t1.origin, t1.destinationFrom yourtable t1Left Join yourothertable t2On t1.ID = t2.IDWhere t1.origin = t2.destinationIf you will it you can achieve it!! |
|
|
|
|
|