Sorting and Evaluating Query Results

If I've built a successful query that returns just the records I want, sometimes I'm content to just let them display in any old order, as in the examples listed so far. But I may also want to build an application that will sort data alphabetically or numerically based on the contents of a certain field. SQL provides a tool for this in ORDER BY.

Ordering Output with ORDER BY

By default, ColdFusion queries return records in the order they find them. In all the query examples from my database of songs, the output results have appeared in the order they're shown in the table in Table 5.1. For my small Elvis database, this hasn't been a problem, but let's look at another example in which I might want to change ...

Get Sams Teach Yourself ColdFusion® in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.