SQLite - 对表进行排序 [英] SQLite - sorting a table
问题描述
我在 SQLlite 中有一个数据库,我想按字母顺序对我的表进行排序.我该怎么做?有没有办法只使用 SQLite 对条目进行排序,或者我必须先将表读入数组,对其进行排序,然后再将其写入数据库?
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 read a table into an array, sort it and afterwards to write it into a database?
这是我的查询:SELECT entry FROM table WHERE id=?"我需要使用此语句从表中获取数据,以便一次只获取一个条目.
Here is my query: "SELECT entry FROM table WHERE id=?" I need to get data from the table using this statement in order to get only one entry at a time.
先谢谢你,伊利亚.
推荐答案
'Select name from table order by name asc'
'asc' 是升序,将按字母顺序为您提供文本字段,相反,'desc' 将按相反的字母顺序为您提供.
'asc' is ascending, will give you the text field in alphabetical order, conversely 'desc' will give it to you in reverse alphabetical order.
作为一般规则,您应该让数据库进行排序.下面的帖子是相关的,可以说,几乎相同.您可能会发现它很有帮助:
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 还是 sort($array)?
这篇关于SQLite - 对表进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!