apache > db
Apache DB Project
 
Font size:      

Mapping Column Values to Return Values

Mapping Column Values to Return Values

Multiple-row VALUES tables are useful in mapping column values to desired return values in queries:

-- get the names of all departments in Ohio
SELECT DeptName
FROM Depts,
(VALUES (1, 'Shoe'),
    (2, 'Laces'),
    (4, 'Polish'))
AS DeptMap(DeptCode,DeptDesc)
WHERE Depts.DeptCode = DeptMap.DeptCode
AND Depts.DeptLocn LIKE '%Ohio%'

You might also find it useful to store values used often for mapping in a persistent table and then using that table in the query.


Previous Page
Next Page
Table of Contents
Index