gpt4 book ai didi

php - PDO 查询中的 SQL 语法错误

转载 作者:行者123 更新时间:2023-12-01 00:46:48 25 4
gpt4 key购买 nike

我在 PHP PDO 中运行这个查询

$stmt = $pdo_conn->prepare("SELECT * from integra_status where type = :type and maintenance_fromdate <= DATE_ADD(NOW(), INTERVAL 7 DAY) and maintenance_todate => DATE_SUB(NOW(), INTERVAL 2 DAY) ");

但我收到此 SQL 语法错误:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 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 '=> DATE_SUB(NOW(), INTERVAL 2 DAY)' at line 1' in /home/integra/public_html/service_status/index.php:56 Stack trace: #0 /home/integra/public_html/service_status/index.php(56): PDOStatement->execute(Array) #1 /home/integra/public_html/index.php(124): include('/home/integra/p...') #2 {main} thrown in /home/integra/public_html/service_status/index.php on line 56

最佳答案

>=,不是=> ...注意顺序颠倒了。

关于php - PDO 查询中的 SQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21025831/

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