Tuesday, March 29, 2011

TIMESTAMP 的使用 memo

查詢某個 TIMESTAMP 欄位在一天內的資料

SELECT * FROM table WHERE DATE_SUB(NOW(), INTERVAL 1 DAY) > time
DATE_SUB 的參考文獻
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add

TIMESTAMP 的幾種 Default 值:
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

No comments: