Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Created July 1, 2017 11:02
Show Gist options
  • Save yano3nora/c9b5d2b96c95127a8d01afd2801dd125 to your computer and use it in GitHub Desktop.
Save yano3nora/c9b5d2b96c95127a8d01afd2801dd125 to your computer and use it in GitHub Desktop.
[mysql: CASE in ORDER BY] use CASE in ORDER BY by mysql. #mysql #sql
ORDER BY
CASE
WHEN $tableA.s_date = '0' THEN $tableA.r_date
ELSE $tableA.s_date
END
DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment