티스토리 뷰

공부

[MySQL] ORDER BY NULL FIRST

승가비 2023. 9. 10. 11:17
728x90
SELECT *
FROM table
ORDER BY
  (start_time IS NULL) DESC,
  start_time DESC
LIMIT 1;

https://stackoverflow.com/questions/25583676/mysql-order-by-date-with-null-first

 

MySQL Order by Date, with NULL first

I have a select statement that I would like to select 1 record from a table. The structure is: id | start_time -------------- 1 NULL 2 2014-08-23 3 2014-09-01 I would like to select the...

stackoverflow.com

 

728x90
댓글