Tab Alleman wrote:
SELECT SomeStuff
FROM Table1 AS T1
LEFT JOIN Table2 AS T2 ON T1.PK = T2.FK1
RIGHT JOIN Table3 AS T3 ON T2.FK2 = T3.PK
WHERE T1.PK=999
Either right-join it or reverse the table order (because you're not
asking for data from "t1 that is like t2 that is like t3 that is like
same results and both varying between .01, .02 seconds to execute.
6 of one half dozen of another or is there an advantage to one?
My guess is that the second syntax is preferred given the reduced row count
for events in it's explain table.
The first statement uses left joins, the second use's Bre
2 | 3 |8 | 3 | 56 | 23 |
+++--+---+---+--++++
1 row in set (0.00 sec)
On Wed, 2003-01-15 at 16:53, Tab Alleman wrote:
> Nice that this came up when it did.. I'm currently struggling with a
> three-table join.
>
> Table1.PK = Table2
To: <[EMAIL PROTECTED]>
|
| cc:
|
Nice that this came up when it did.. I'm currently struggling with a
three-table join.
Table1.PK = Table2.FK1
Table3.PK = Table2.FK2
My last effort looks something like:
SELECT SomeStuff
FROM Table1 AS T1
LEFT JOIN Table2 AS T2 ON T1.PK = T2.FK1
RIGHT JOIN Table3 AS T3 ON T2.FK2 = T3.PK
Let me give this a try. I've done 3 and 4 table joins, but I did a
little trial and error before I got it right.
To break it down, you want to get three things:
1) All meetings that fall under a particular event
select * from meetings where eid=2
2) All people id's that are part of that selected
I've wanted to post this query example a few times (and I hope I got it
right; mornings aren't my best time) ... multiple JOINs:
SELECT stuff
FROM table1
LEFT JOIN table2
ON table1.fk = table2.pk
LEFT JOIN table3
ON table2.fk = table3.pk
WHERE other_conditions
I want a list of all the people in all the meetings in a given event, for
the purpose of printing all their schedules.
I can get a list of meetings in an event given the event id with the
following query:
select meetings.id from meetings where eid=2;
People are assigned meetings in the table