Answer the question
In order to leave comments, you need to log in
Sorting sql in strict order, how to set this query in Yii2?
Hello.
----
Perhaps someone faced such a problem SELECT * FROM `category` ORDER BY `priority`;
Outputs:
1
10
100
111
2
22
202
3
333
4
SELECT * FROM `category` ORDER BY (priority+0);
1
2
3
4
10
22
100
111
202
333
Answer the question
In order to leave comments, you need to log in
Who had a similar problem, just make a query like this in the database:
Category::find()->orderBy('LENGTH(priority), priority')->all()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question