Answer the question
In order to leave comments, you need to log in
How to get data from database in order?
Select * from tablename where model = 'A' or model = 'B'
with such a record, the result is unpredictable, 'B' can be found before 'A', the array is located like this ['B', 'A'], but you need [' A', 'B']
Answer the question
In order to leave comments, you need to log in
SELECT * FROM `table_name` WHERE `column_name` IN ('A', 'B', 'C') ORDER BY FIELD (`column_name`, 'A', 'B', 'C')
I don’t know if this is effective or not, but, it seems, I managed to solve it like this:
select * from tablename where model = 'A' union select * from tablename where model = 'B',
you need the order to be exactly as specified in the query
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question