VbzCart/docs/queries/qryCtg build sub

From Woozle Writes Code
< VbzCart‎ | docs‎ | queries
Jump to navigation Jump to search

Details

SQL

<section begin=sql /><mysql>CREATE OR REPLACE VIEW qryCtg_build_sub AS

 SELECT
   s.ID_Item,
   s.CatNum,
   (
     s.isActive 
     AND tg.isActive
     AND tgi.isActive
     AND (c.ID_Supercede Is Null)
      ) AS isForSale,
   c.isCloseOut,
   s.isActive,
   s.ID_Title,
   tgi.ID_ItTyp,
   tgi.ID_ItOpt,
   tgi.ID_ShipCost,
   tgi.PriceBuy,
   tgi.PriceSell,
   tgi.PriceList,
   IFNULL(tgi.Descr,CONCAT_WS(' / ',tgt.GroupDescr,o.Descr)) AS ItOpt_Descr_part,
   it.NameSng,
   s.ID_CTG_Title,
   s.ID_CTG_Item,
   tgi.Descr AS GrpItmDescr,
   tgt.GroupDescr AS TitleGroupDescr,
   o.Descr AS OptionDescr,
   s.CatSfx,
   CONCAT(tg.Sort,it.Sort,o.Sort) AS ItOpt_Sort,
   tgt.GroupCode AS GrpCode,
   tgt.GroupDescr AS GrpDescr,
   tgt.GroupSort AS GrpSort
 FROM
 ( ( ( ( (ctg_updates AS s LEFT JOIN ctg_groups AS tg ON s.ID_CTG_Group = tg.ID
          ) LEFT JOIN qry_ctg_titles_active AS tgt ON s.ID_CTG_Title = tgt.ID
        ) LEFT JOIN ctg_items AS tgi ON s.ID_CTG_Item = tgi.ID
      ) LEFT JOIN ctg_sources AS c ON tgt.ID_Source = c.ID
    ) LEFT JOIN cat_ioptns AS o ON tgi.ID_ItOpt = o.ID
  ) LEFT JOIN cat_ittyps AS it ON tgi.ID_ItTyp = it.ID;</mysql>

<section end=sql />