
445
DEVELOPING
COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Las
t
upda
te
d 8/5/2010
Note:
Query of Queries does not support aliases for table names.
SELECT Fir ' ' + 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
clause works correctly in Query of Queries. However the following
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:
LA ', ' + FIRSTNAME
LASTNAME || ', ' || FIRSTNAME
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...