I want based on a value queried from another table order ASC or DESC.
So something like this:
SELECT *
FROM table
ORDER BY
CASE (SELECT sorting from table2 WHERE table2.id = ?)
WHEN 1 THEN table.date ASC END
WHEN 0 THEN table.date DESC END
END
Is anything like that available in MySQL?
I’ve seen for MS-SQL Server some solution: how to order 2 SQL Fields in asc and desc dynamically
EDIT: I just saw I made a mistake in the description, fixed.
negation works if your column is numeric. if it’s a string, you might be able to find another function to map high values to low values…