Re: Strange Query Error...
| From: | Bastien | Date: | Sat, 27 Nov 2010 18:07:26 +0000 |
| Subject: | Re: Strange Query Error... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309718@lists.php.net to get a copy of this message | ||
On 2010-11-27, at 12:30 PM, Don Wieland <donw@dwdataconcepts.com> wrote:
> Hi gang,
>
> I am executing a query via PHP that gives me a PHP 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 'AND
> m.
Preferred_First_Name LIKE 'Don' AND
> m.Preferred_Last_Name LIKE 'Wielan' at line 1
>
> but when I copy the ECHO of the select query and run it in Sequel Pro Query, it returns no
> error.
>
> Here is the query:
>
> select m.* from Members m inner join Member_Years my on m.aucciim_id = my.member_id where now()
> < DATE_ADD(DATE_SUB(concat(member_year + 1,'-07-01'),
> INTERVAL 1 DAY), INTERVAL 30 DAY) AND m.Preferred_First_Name LIKE
> 'Don' AND m.Preferred_Last_Name LIKE 'Wieland'
> group by m.AUCCIIM_ID order by m..preferred_last_name
>
> What is causing it to choke via PHP?
>
> Thanks!
>
> Don
Try removing the backticks around the table names. If you do use them, then all values (field names
and table names) need it.
Bastien Koert
Sent from my iPhone