在准备好的声明中,我必须仅使用MySQL中的notifyplayers表来获取当前日期为'In'的玩家的'计数'。我在查询中使用了'curdate()/ current_date()'函数,但count始终返回为'0'
查询:
select count(1) as count
from notifyplayers
where lower(availability) = 'in' and notifydate = curdate();
请查看表格截图:
有人可以帮助找出查询中的问题。
答案 0 :(得分:1)
您的日期有时间组件,因此一种方法是:
select count(1) as count
rom notifyplayers
where lower(availability) = 'in' and
date(notifydate) = curdate();
但是,我建议:
select count(1) as count
rom notifyplayers
where lower(availability) = 'in' and
notifydate >= curdate() and
notifydate < curdate() + interval 1 day;
答案 1 :(得分:0)
试试这个:
select count(1) from notifyplayers
where lower(availability) = 'in' and date(notifydate) = date(curdate());