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 |
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-11-16 : 16:22:03
|
| I understand joining tables give all rows because of matching. the following gives me 705 rows. But as soon as I add sa.FromAirport, sa.ToAirport , the nubmer of rows jump to 1750. How can re-write this and still get 705 records with column from sa? |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2009-11-16 : 16:25:05
|
| You do understand that tables have relationships, just like a parent has to their Child?For Example, I am a father, or 1 row in the Parent TableI happen to have 3 children, or 3 rows in the Child tableIf I only Select from the parent table looking for me, I get 1 rowIf I then Join to the child table ON me, then the result would be 3 rows?Understand?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-11-16 : 16:26:23
|
| Brett, So the query is good. hmm. what is this link (http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=129836) talking about |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-11-16 : 16:56:48
|
| This works...SELECT DISTINCT a.event, a.name, a.phone, b.flightsFROM (SELECT DISTINCT id, event, name, phone from table1) as a LEFT OUTER JOIN (SELECT DISTINCT id, flights from table2) AS b ON a.ID = b.ID |
 |
|
|
|
|
|
|
|