------------------------------------------------
| UserId | Checktime | Checktype
| 1 | 12/05/2015 09:00:00:0000 | I
| 1 | 12/05/2015 18:00:00:0000 | O
| 1 | 12/04/2015 09:00:00:0000 | I
| 1 | 12/04/2015 18:00:00:0000 | O
| 2 | 12/05/2015 09:00:00:0000 | I
| 2 | 12/05/2015 18:00:00:0000 | O
| 2 | 12/04/2015 09:00:00:0000 | I
| 2 | 12/04/2015 18:00:00:0000 | O
我想只检索Checktime
= UserId
= 1
和date
= 12/05/2015
和Checktype
= {{1} I
的时间在我的结果集中。
答案 0 :(得分:0)
您选择查询以检索数据并过滤数据,其中日期大于2015年4月12日且小于13/04/2015且userId = 1.
所以你的查询会是这样的。
Mysl查询: -
SELECT DATE_FORMAT(Checktime,'%H:%i:%s') as TIME from TABLE_NAME where UserId=1 and Checktype='I' and Checktime>='12/04/2015' and Checktime <'13/04/2015'
编辑: - SQL Server 2008
SELECT CONVERT(TIME,Checktime) AS TIME from TABLE_NAME where UserId=1 and Checktype='I' and Checktime>='12/04/2015' and Checktime <'13/04/2015'