P粉8086974712023-08-23 13:48:18
升序是大多數(如果不是全部)DBMS的預設排序方式,所以你的語句在這方面有點奇怪,但是無論如何,你可以透過在每個欄位上新增ASC或DESC來指定排序方式。
你的語句將變成:
SELECT title , project_index FROM projectdetail WHERE project_index BETWEEN 1 AND 6 ORDER BY title ASC , project_index ASC
編輯
如@Arvo和@Dems所提到的,你目前是先依照標題排序,如果標題相同,則依照project_index排序。如果你想要project_index先排序,你必須把它放在ORDER BY子句的第一個。
你的語句將變成:
SELECT title , project_index FROM projectdetail WHERE project_index BETWEEN 1 AND 6 ORDER BY project_index ASC , title ASC
因為ASC是預設的排序順序,所以你可以省略它們:
SELECT title , project_index FROM projectdetail WHERE project_index BETWEEN 1 AND 6 ORDER BY project_index , title