Answer the question
In order to leave comments, you need to log in
How in MySQL (SQL) can you output (sort) in your own way?
There is a city table in the database:
id | name
1 | Rostov
2 | Moscow
3 | Krasnodar.
And how can you display in this order: Moscow, Rostov, Krasnodar without changing the id?
Answer the question
In order to leave comments, you need to log in
Enter an additional pos field if you need to manually set the entry's unique location in the list. In this case, the id does not change, and you can set the order yourself:
id | pos | name
1 | 2 | Ростов
2 | 1 | Москва
3 | 3 | Краснодар
If you need to sort once, then copy to an adjacent table with the correct sort.
If you need to sort by position, then use the first option above.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question