[odb-users] Sorted Query Results

Boris Kolpackov boris at codesynthesis.com
Tue Nov 6 05:19:58 EST 2012


Hi Jordan,

Jordan J. Neuhart <jneuhart at tlirr.com> writes:

> Is it possible to have a query return a result set sorted by a
> particular database column (similar to the "ORDER BY" SQL clause)

Yes, you can add the ORDER BY clause as shown below (based on the
person object from the hello example):

db->query<person> ((query::first == "John") + "ORDER BY" + query::age);

We are also planning to add some syntactic sugar around this in one
of the future versions so that you would be able to write something
like this:

db->query<person> ((query::first == "John") + order_by (query::age));

Boris



More information about the odb-users mailing list