mysql 查询指定Timestamp或dateTime格式的时间段的数据
1.传统的方法
SELECT * FROM customer lastlogintime >= '2015-01-01 13:50:42' AND lastlogintime <= '2015-02-06 00:00:00' ORDER BY ID DESC
但是传统的方法效率很低。
2.采用UNIX_TIMESTAMP,能有效的提高效率。
SELECT * FROM customer WHERE UNIX_TIMESTAMP(lastlogintime) >= UNIX_TIMESTAMP('2015-01-01 13:50:42') AND UNIX_TIMESTAMP(lastlogintime) <= UNIX_TIMESTAMP('2015-02-06 00:00:00') ORDER BY ID DESC
posted on 2015-02-04 15:04 w_xunfangA 阅读(13380) 评论(0) 编辑 收藏 举报