Mysql 技巧

order by条件:

SELECT * FROM tablename 
WHERE id_one=27 OR id_two=27 
ORDER BY 
  CASE WHEN id_one=27 THEN timestamp_one END DESC, 
  CASE WHEN id_two=27 THEN timestamp_two END DESC

  

posted @ 2016-04-07 17:09  wujixing909  阅读(79)  评论(0编辑  收藏  举报