SQLite - sorting a table

后端 未结 3 1424
一个人的身影
一个人的身影 2021-01-12 07:15

I have a database in SQLlite and I\'d like to sort my table in an alphabetical order. How can I do it? Is there a way to sort entries using only SQLite or do I have first to

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-12 07:58

    'Select name from table order by name asc' 
    

    'asc' is ascending, will give you the text field in alphabetical order, conversely 'desc' will give it to you in reverse alphabetical order.

    Edit: as a general rule, you should let the database do the sorting. The below post is related, and arguably, almost the same. You might find it helpful:

    PHP/SQL: ORDER BY or sort($array)?

提交回复
热议问题