我的表格如下:
Name Created
ganesh 2010-06-25 10:54:54
vasant 2010-06-25 11:54:54
charlie 2010-06-25 12:54:54
sam 2010-06-25 13:54:54
vasamtj 2010-06-25 01:54:54
jack 2010-06-25 02:54:54
nima 2010-06-24 10:54:54
kumar 2010-06-24 10:54:54
jay 2010-06-24 10:54:54
paala 2010-06-23 10:54:54
test1 2010-06-23 10:54:54
jhon 2010-06-22 10:54:54
我想只显示今天的参赛作品,在这种情况下我不想增加时间:
SELECT response FROM ost_ticket_response WHERE staff_id = 1 AND created ='now()'
此查询也会随时间检查。
答案 0 :(得分:1)
您的表格信息不完整,但此查询可以满足您的需求:
SELECT *
FROM ost_ticket_response
WHERE DATE_FORMAT(Created, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d');
您可以从代码
中传递字符串值DATE_FORMAT(NOW(), '%Y-%m-%d')
,而不是'2010-06-25'
答案 1 :(得分:1)
非常粗鲁,但是:
SELECT response FROM ost_ticket_response WHERE staff_id = 1 AND created BETWEEN from_days(to_days(now())) AND from_days(to_days(now())+1)
答案 2 :(得分:0)
WHERE Created >= date_format(CURRENT_TIMESTAMP(),'%Y%m%d000000')
答案 3 :(得分:0)
此查询解决了我的问题:
SELECT count( response_id ) as cnt, staff_id FROM ost_ticket_response WHERE CAST( created AS Date ) = CURRENT_DATE( ) GROUP BY staff_id
此查询是否有任何缺点?
答案 4 :(得分:0)
为什么不:
SELECT response FROM ost_ticket_response WHERE staff_id = 1 AND DATE(created) = CURDATE()