php - Conditionally order by another column
713
Solution:
You should better provide some data sample and expected result, but so far you can try:
SELECT * FROM myTable1
LEFT JOIN myTable2 b
ON myTable1.id = b.id
WHERE myTable1.id !='foo'
ORDER BY CASE WHEN b.column2 IS NULL myTable1.dateColumn ELSE NULL END DESC, b.column2 ASC
Answer
Solution:
You can put CASE Statements inside of an
ORDER BY
Answer
Solution:
You can use a function in the order part; something like the following: