VbzCart/docs/queries

From Woozle Writes Code
< VbzCart‎ | docs
Revision as of 01:41, 3 October 2007 by imported>Woozle (qryCbx_Items - not tested; need qryCatNum_Items too.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Navigation

VbzCart: data views

Overview

"Views" in MySQL are like SELECT "queries" in MS Access, i.e. they pull data from existing tables and are themselves usable as data sources in much the same way that tables are (and in which result sets from functions are not).

Views

Some common prefixes:

  • qryCbx_: queries used for filling comboboxes. The unique ID will always be the first field, and the text to display will always be the second field; additional fields may be provided for use in further qryCbx_ queries which show a subset of the results.
  • qryCatNum_: queries which build catalog numbers, possibly including other information from the tables they draw on in so doing.

qryCbx_Items

<sql>SELECT

 i.ID,
 CONCAT(
   IF(i.isPulled,CONCAT('!PULLED (',i.ID,')'),),
   i.CatNum,
   IF(i.Supp_CatNum IS NULL,,CONCAT('[',i.SuppCatNum,']')),
   IF(i.isForSale,,' n/a'),
   i.Descr)
     AS Descr,
 i.isForSale

FROM qryCatNum_Items AS i ORDER BY NOT i.isPulled, i.isForSale, i.CatNum;</sql>