I need a MySQL conditional ORDER BY statement for a datetime field. I have a table with posts which I would like to order in the following way: all future posts
How about something like this? Select twice and union the results.
Select * from (SELECT post_status, post_date, post_title
FROM wp_posts WHERE post_status IN ('future')
ORDER BY post_status ASC ) alias1
UNION
Select * from (SELECT post_status, post_date, post_title
FROM wp_posts WHERE post_status IN ('publish')
ORDER BY post_status DESC ) alias2