VbzCart/procs/Upd Titles fr CatItems

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< VbzCart‎ | procs
Revision as of 19:41, 8 March 2009 by Woozle (talk | contribs) (New page: ==About== * '''Purpose''': sets some fields in {{vbzcart|table|_titles}} after that has been filled in by {{vbzcart|proc|Upd_Titles_fr_Depts}} ==SQL== <section begin=sql /><mysql>CREATE PR...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About

SQL

<mysql>CREATE PROCEDURE Upd_Titles_fr_CatItems()

   UPDATE _titles AS t LEFT JOIN (
     SELECT
       ID_Title,
       SUM(IF(i.isForSale,1,0)) AS cntForSale,
       SUM(IF(i.isInPrint,1,0)) AS cntInPrint,
       SUM(i.qtyInStock) AS qtyInStock,
       MIN(i.PriceSell) AS currMinSell,
       MAX(i.PriceSell) AS currMaxSell
      FROM cat_items AS i GROUP BY ID_Title
     ) AS ig ON ig.ID_Title=t.ID
     SET
       t.cntForSale = ig.cntForSale,
       t.cntInPrint = ig.cntInPrint,
       t.qtyInStock = ig.qtyInStock;</mysql>