Adobe COLDFUSION 9 Manual page 450

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Note: Query of Queries does not support aliases for table names.
SELECT FirstName + ' ' + LastName AS fullname
from Employee;
The following examples rely on these two master queries:
<cfquery name="employee" datasource="2pubs">
SELECT * FROM employee
</cfquery>
<cfquery name="roysched" datasource="2pubs">
SELECT * FROM roysched
</cfquery>
ORDER BY example
<cfquery name="order_by" dbtype="query">
SELECT (job_id || job_lvl)/2 AS job_value
FROM employee
ORDER BY job_value
</cfquery>
GROUP BY example
<cfquery name="group_by" dbtype="query">
SELECT lorange || hirange AS x, count(hirange)
FROM roysched
GROUP BY x
</cfquery>
HAVING example
<cfquery name="having" dbtype="query">
SELECT (lorange || hirange)/2 AS x,
COUNT(*)
FROM roysched GROUP BY x
HAVING x > 10000
</cfquery>
Handling null values
Query of Queries uses Boolean logic to handle conditional expressions. Proper handling of NULL values requires the
use of ternary logic. The
IS [NOT] NULL
expressions do not work properly when the column breed is NULL:
WHERE (breed > 'A')
WHERE NOT (breed > 'A')
The correct behavior should not include NULL breed columns in the result set of either expression. To avoid this
limitation, add an explicit rule to the conditionals and rewrite them in the following forms:
WHERE breed IS NOT NULL AND (breed > 'A')
WHERE breed IS NOT NULL AND not (breed > 'A')
Concatenating strings
Query of Queries support two string concatenation operators: + and ||, as the following examples show:
LASTNAME + ', ' + FIRSTNAME
LASTNAME || ', ' || FIRSTNAME
clause works correctly in Query of Queries. However the following
Last updated 8/5/2010
445

Advertisement

Table of Contents
loading

Table of Contents