PDO查询中的SQL语法错误

时间:2014-01-09 16:29:53

标签: php mysql sql pdo

我在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

2 个答案:

答案 0 :(得分:3)

>=,而不是=> ...请注意订单的撤销。

答案 1 :(得分:2)

maintenance_todate =>应为maintenance_todate >=