[thelist] sql statement

Ed McCarroll Ed at ComSimplicity.com
Wed Mar 30 13:38:07 CST 2005


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