SQLite - sorting a table

I have a database in SQLlite and I would like to sort the table in alphabetical order. How can I do it? Is there a way to sort records using only SQLite, or do I need to read the table in the array first, sort it and then write to the database?

Here is my query: "SELECT entry FROM table WHERE id =?" I need to get data from a table using this operator in order to get only one record at a time.

Thanks in advance, Ilya.

+7
sqlite
source share
3 answers
'Select name from table order by name asc' 

"asc" grows, it will give you a text field in alphabetical order, on the contrary, "desc" will give it to you in reverse alphabetical order.

Edit: Generally, you should allow the database to sort. The next post is related, and perhaps almost the same. You may find it helpful:

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

+13
source share

It is also worth emphasizing that the data order in any table in the SQL database or obtained from them using a query that does not include the order by clause is not defined.

In practice, direct reading of a table without order will retrieve data in some fixed order and often insertion order. However, relying on it is always a mistake, although it is often found often.

+2
source share

If you want to sort a table without case sensitivity or with a specific locale (and not with English), you need to add the sorting to your sqlite. Here is an example of how to do this.

0
source share

All Articles