gpt4 book ai didi

mysql - CURDATE 给出错误

转载 作者:行者123 更新时间:2023-11-28 23:39:10 25 4
gpt4 key购买 nike

我有一个 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

最佳答案

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

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

关于mysql - CURDATE 给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34884902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com