> -----Original Message-----
> From: Karl DeSaulniers [mailto:k...@designdrumm.com]
> Sent: 25 September 2016 09:59
> To: PHP List Database <php-db@lists.php.net>
> Subject: Re: [PHP-DB] Corn job anomaly
>
> Now I am getting an error with mysql syntax.
>
> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf
> ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND
> cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
>
> is giving me this error:
>       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
> '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1

I don't think INTERVAL works like that - you probably need something like:

    ... cf.Earliest_Pickup <= DATE_ADD(CURDATE(), INTERVAL 
".($Num_Days_Away+1)." DAY) AND ...

Incidentally, as I understand it CURDATE() does exactly the same as 
DATE(NOW()), and is probably more readable.

Cheers!

Mike

--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
110 Queen Square House, 80 Woodhouse Lane,
Leeds Beckett University, Leeds LS2 8NU,  United Kingdom
E & S4B: m.f...@leedsbeckett.ac.uk     T: +44 113 812 4730

To view the terms under which this email is distributed, please go to:-
http://disclaimer.leedsbeckett.ac.uk/disclaimer/disclaimer.html

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to