我有以下SQL查询语句:
SELECT subject, sender_list, date, uid
FROM messages
WHERE folder_id = 3
请告诉我如何指定查询排序顺序?
谢谢。
答案 0 :(得分:12)
实际上很容易。以下是按“主题”对查询进行排序的示例:
SELECT subject, sender_list, date, uid
FROM messages
WHERE folder_id = 3
ORDER BY subject ASC
这将订购您的清单A-Z。如果您想订购Z-A清单,请使用:
ORDER BY subject DESC
答案 1 :(得分:1)
使用“ORDER BY”
有关详细信息,请查看w3schools
答案 2 :(得分:0)
这有效:
SELECT subject, sender_list, date, uid
FROM messages
WHERE folder_id = 3
ORDER BY subject ASC
但是我不介意最后将“ asc”取消,因为默认情况下ASC为true。