Sorting in CFQL

CFQL allows you to sort the loaded records by specifying the “ORDER BY” statement in your queries.

The order by syntax is pretty much the SQL syntax:

order by <identifier1> [asc | desc], <identifier2> [asc | desc], … , <identifierN> [asc | desc]

Note that identifiers can be expressions navigating your model such all:

load order by Customer.Reference

The expression orders all records of the declaring entity by the Reference of its related Customer (Customer is a relation property of the declaring entity).

Other than that, ASC and DESC keywords work exactly as in SQL.

Since the sort order is defined in a CFQL query, the generated stored procedure will always sort at run time using the specified column and direction (by the way if no direction is specified, ascending is used by default).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s