[thelist] mysql - null - returns results anyway

r937 rudy at r937.com
Mon Dec 21 18:26:04 CST 2009


nice one phil

i personally would not parenthesize the joins

(you must have picked up that bad habit from ms access)

and if there's only one vendor being selected, there's not much point in 
sorting on the vendor name

SELECT p3_products.id             AS pid
     , p3_products.name           AS product_name
     , p3_vendors.name            AS vendor_name
     , p3_product_categories.name AS category_name
     , p3_products.jos_content_id AS product_jos_content_id
     , p3_vendors.jos_content_id  AS vendor_jos_content_id
     , p3_product_categories.jos_content_id AS category_jos_content_id
  FROM p3_vendors
LEFT OUTER
  JOIN p3_products
    ON p3_products.vendor_id = p3_vendors.id
LEFT OUTER
  JOIN p3_product_categories
    ON p3_product_categories.id = p3_products.category_id
 WHERE p3_vendors.id = '21'
ORDER
    BY product_name ASC

;o)


rudy
http://simply-sql.com/ 




More information about the thelist mailing list