[thelist] sql statement

Dan McCullough dan.mccullough at gmail.com
Wed Mar 30 14:19:09 CST 2005


wow thats awesome.  :)

now a follow up question is and this gets to where I'm seeing if what
it returned is a good thing or a bad thing.

What I got back is what I asked for, but because size is returning
more then one result, because the sizes for this product is more then
one.  what i got back was the product listed 9 times, one for each
size in the product.



On Wed, 30 Mar 2005 11:38:07 -0800, Ed McCarroll <Ed at comsimplicity.com> wrote:
> Dan,
> 
> I suspect you want to something that looks like this:
> 
>  SELECT P.productid, P.<fields from first product record>,
>         S.abrv,
>         P2.<fields from related product record>
>  FROM products P
>    INNER JOIN prod_size PS
>      ON P.productid = PS.productid
>    INNER JOIN sizes S
>      ON PS.sid = S.sid
>    LEFT OUTER JOIN products P2
>      <OUTER in case there is no related record>
>      ON P.<related productid> = P2.productid
>  WHERE <all that script stuff>
>  ORDER BY P.sort_order
> 
> --
> Ed McCarroll                                  (310) 838-4330
> Ed at ComSimplicity.com            http://www.ComSimplicity.com
>


More information about the thelist mailing list