2014-01-09 157 views
0

我在PHP PDO運行此查詢SQL語法錯誤

$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 
+0

'maintenance_todate =>'應該是'maintenance_todate> ='。 – user2989408

回答

2

maintenance_todate =>maintenance_todate >=

3

>=,不=> ...注意的逆轉命令。

+0

完美謝謝 – charlie