I have a SELECT with a GROUP_CONCAT column as follows:
SELECT
m.*,
GROUP_CONCAT(s.id ORDER BY s.id ASC SEPARATOR ', ') AS schedule_ids
FROM months m
LEFT JOIN schedule s
ON (MONTH(s.start_date) = m.id) OR (MONTH(s.end_date) = m.id)
GROUP BY m.id
This column currently returns a comma separated string of 2 IDs, eg: 1, 2 or 11, 12.
I want to add an IF condition to the ORDER BY, whereby in the specific instance where the IDs returned are 1, 12, the ORDER BY should be DESC, i.e. it should return 12, 1, otherwise keep it as ASC.
How can I do this?