Josh Trutwin wrote:

>>SELECT table1.bunch, table2.of, table3.stuff FROM table1
>>   INNER JOIN table2 ON table2.some_id
>>   INNER JOIN table3 ON table3.some_id
>>WHERE table1.some_id = table2.some_id AND table1.some_id = table3.some_id;
>>
>  
>
Your where is sort of in the wrong place ...

SELECT table1.bunch, table2.of, table3.stuff FROM table1
 INNER JOIN table2 ON table2.some_id = table1.some_id
 INNER JOIN table3 ON table3.some_id = table1.some_id;

... or, for a more concrete example (if a tad contrived) ...

SELECT PhoneNumbers.Number as FaxNumber FROM Customers
 LEFT JOIN CustomerPhoneNumbers ON CustomerPhoneNumbers.CustomerID = 
Customers.ID
 LEFT JOIN PhoneNumbers ON PhoneNumbers.ID = 
CustomerPhoneNumbers.PhoneNumberID
 WHERE CustomerPhoneNumbers.Type = 'fax' AND Customers.ID = '443';

It would operate on data such as: Customers: { ID = 443 }, 
CustomerPhoneNumbers { CustomerID = 443, PhoneNumbersID = 272, Type = 
'fax'; CustomerID = 443, PhoneNumbersID = 273, Type = 'phone' }, 
PhoneNumbers { ID = '272', Number = "555-1212"; ID = '273', Number = 
"555-1213" }

PS, I actually use this table structure for phone numbers, with great 
success.

PPS, would you believe that message didn't pass the spam filter, since it checks for 
stupid things like "SQL" and "QUERY"?

-- 
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to