charlie
charlie

Reputation: 1384

SQL Syntax error in PDO Query

I am running this query in 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) ");

but im getting this SQL Syntax error:

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

Upvotes: 0

Views: 155

Answers (2)

user2989408
user2989408

Reputation: 3137

maintenance_todate => should be maintenance_todate >=

Upvotes: 2

Marc B
Marc B

Reputation: 360672

>=, not => ... note the reversal of the order.

Upvotes: 3

Related Questions