When the database processes a SELECT statement, it returns a record set containing the requested data. The format of a record set is a table with rows and columns. For example, if you write the following query:
SELECT * FROM employees WHERE DeptID=3
The query returns the following table:
Because the data returned to ColdFusion by a SELECT statement is in the form of a database table, ColdFusion lets you write a SQL query on the returned results. This functionality is called query of queries. For more information on query of queries, see Accessing and Retrieving Data.
The next example uses a SELECT statement to return only a specific set of columns from a table:
SELECT LastName, FirstName FROM employees WHERE DeptID=3
The query returns the following table: