[thelist] mysql - null - returns results anyway

Bob Meetin bobm at dottedi.biz
Mon Dec 21 22:47:18 CST 2009


r937 wrote:
> 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/
>
I will try this as well; with Phil's help Christmas came early.  Much 
X-thanx.

What is not seen here is that there are multiple where/and options.  In 
some cases the vendor id is not specified, so the order by helps there.  
I have other options that come into their own if the viewer specifies.  
Still, in my mind I was thinking something incorporating 'is null', not 
/dev/null...




More information about the thelist mailing list