开发者

How can I specify sql sort order in sql query

I have the follow SQL query statement:

SELECT subject, sender_list, date开发者_Python百科, uid
FROM messages
WHERE folder_id = 3

Can you please tell how can I specify query sort order?

Thank you.


It's actually quite easy. Here's an example to sort your query by the "subject":

SELECT subject, sender_list, date, uid
  FROM messages
 WHERE folder_id = 3
 ORDER BY subject ASC

This will order your list A-Z. If you want to order your list Z-A then use:

ORDER BY subject DESC


Use the "ORDER BY"

For more information check out w3schools


this works:

SELECT subject, sender_list, date, uid
  FROM messages
 WHERE folder_id = 3
 ORDER BY subject ASC

but i wouldn't mind taking off the 'asc' at the end being that ASC is true by default.

https://www.w3schools.com/sql/sql_orderby.asp

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜