DB/MYSQL
[ MYSQL ] DATETIME Null값 체크
라넌.B
2021. 10. 21. 14:16
증상
DATETIME 수정이 일어난 경우 0000-00-00 이 기본 값으로 입력됨
해결
UNIXTIME 기준으로 검증한다
IF(UNIX_TIMESTAMP(O.delivery_complete_time) = 0,'미입력', O.delivery_complete_time) AS delivery_complete_time
관련링크
https://stackoverflow.com/questions/559590/selecting-empty-mysql-datetime-fields
Selecting empty mysql datetime fields
Is there a better way to select empty datetime fields than this? SELECT * FROM `table` WHERE `datetime_field` = '0000-00-00 00:00:00'
stackoverflow.com