Daniel Convissor wrote:
PHP code. Most importantly, if you name everything "id," then you have to explicitly spell out your JOIN statements in an ON clause

SELECT product_name, vendor_name
FROM product
JOIN vendor ON (vendor.id = product.vendor_id)

When it's so much easier to take advantage of USING clause:

SELECT product_name, vendor_name
FROM product
JOIN vendor USING (vendor_id)

It's always seemed easier and clearer to me to use WHERE instead of JOIN (where the table IDs are indeed named id, and the foreign keys are labeled with the table name):

SELECT product_name, vendor_name
FROM product, vendor
WHERE vendor.id = product.vendor_id

but maybe that's just my ignorance


--
=================
Michael Southwell
Vice President, Education
NYPHP TRAINING:  http://nyphp.com/Training/Indepth
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show_participation.php

Reply via email to