> 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) ...

Odd, the example I typed was from a working, albeit slow example.  Maybe
that's why the performance of that query is so dang slow.

Thanks for the examples, this is great stuff for my archives.  Looks like
I have some work to do...

Josh

> 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.



---------------------------------------------------------------------
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