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
ng as many rows as there are
> in Table3. Where am I goofing?
>
> TIA,
> Tab
> mysql
>
> -Original Message-
> From: Michael T. Babcock [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 8:30 AM
> To: Josh L Bernardini
> Cc: [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>
|
| cc:
|
PROTECTED]
Subject: Re: three table join
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
O
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