Answer the question
In order to leave comments, you need to log in
How to make a selection sorted by two fields in mysql?
there is a table
col1 | col2
|
null | 2
1 | null
null | 4
3 | null
null | 6
5 | null
SELECT * FROM table ORDER BY col1, col2
, then the selection is 2,4,6,1,3,5, that is, sorted by each of these fields separately
Answer the question
In order to leave comments, you need to log in
SELECT COALESCE(col1,col2) as someName
ORDER BY someName
UPD: Just take your time and figure out how the COALESCE function works. If you have both fields null or both have a value, you may need different results and a different approach.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question