views:

28

answers:

2

How do I sort out some data according to an where clause and a order by clause using object query language this is the query that I'm using but i'm not sure if it is working or not.

SELECT user from user.User as user WHERE user.status=1 order by user.username

Thanks.

A: 

I think it should be written more like

SELECT `users`.* FROM `users` WHERE `users`.`status` = 1 ORDER BY `users`.`username`

This assumes you have a table called users and want to select all rows where status is 1, ordered by the username column.

Josh K
A: 

Your query looks fine. From the reference documentation:

14.11. The order by clause

The list returned by a query can be ordered by any property of a returned class or components:

from DomesticCat cat
order by cat.name asc, cat.weight desc, cat.birthdate

The optional asc or desc indicate ascending or descending order respectively.

Pascal Thivent