Download Informix Guide to SQL: Tutorial

Transcript
Some Query Shortcuts
The associative nature of the SELECT statement allows you to use an alias
before you define it. In Query 2-78a, the aliases s for the stock table, c for the
catalog table, and m for the manufact table are specified in the FROM clause
and used throughout the SELECT and WHERE clauses as column prefixes.
Compare the length of Query 2-78a with Query 2-78b, which does not use
aliases.
Query 2-78b
SELECT stock.stock_num, stock.manu_code, stock.description,
stock.unit_price, stock.unit, catalog.catalog_num,
catalog.cat_descr, catalog.cat_advert,
manufact.lead_time
FROM stock, catalog, manufact
WHERE stock.stock_num = catalog.stock_num
AND stock.manu_code = catalog.manu_code
AND stock.manu_code = manufact.manu_code
AND stock.manu_code IN ('HRO', 'HSK')
AND stock.stock_num BETWEEN 100 AND 301
ORDER BY catalog_num
2-76
Informix Guide to SQL: Tutorial