CURDATE给出了错误

时间:2016-01-19 19:01:37

标签: mysql sql date mysqli

我有一个INSERT语句,

$stmt = $mysqli->prepare("INSERT INTO numbertable (numbers, numdate, salesperson, color) VALUES (?, NOW(), ?, ?)");

我的SELECT语句如下所示:

$result = $mysqli->query("SELECT COUNT FROM numbertable WHERE DATE(numdate) == CURDATE()");

当我运行select语句时,出现以下错误。有人知道那可能是什么吗?

SELECT COUNT FROM numbertable WHERE DATE(numdate) == CURDATE()
 LIMIT 0, 30 
MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== CURDATE()
LIMIT 0, 30' at line 1 

1 个答案:

答案 0 :(得分:1)

在mySQL中,您需要=作为等号,而不是==。应该是:

SELECT COUNT FROM numbertable WHERE DATE(numdate) = CURDATE()