开发者

Object query language | execute both "order by" and "where" clauses

开发者 https://www.devze.com 2023-01-06 04:40 出处:网络
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 o开发者_Python百科r not.

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 o开发者_Python百科r not.

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

Thanks.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消