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
精彩评论