MYSQL ORDER BY CASE Issue
Solution 1:
SELECT id_one, id_two, timestamp_one, timestamp_two
FROM tablename
WHERE id_one = 27
OR id_two = 27
ORDER BY
CASE
WHEN id_one=27 THEN timestamp_one
WHEN id_two=27 THEN timestamp_two
END DESC
Solution 2:
SELECT
id_one,
id_two,
(CASE
WHEN id_one=27 THEN timestamp_one
WHEN id_two=27 THEN timestamp_two
END) as timestamp
FROM tablename
ORDER BY timestamp DESC