Bug #48030 date query error
Submitted: 13 Oct 2009 20:00 Modified: 14 Oct 2009 3:21
Reporter: Lester Tarranza Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:microsoft windows XP OS:Windows (version 2002 SP2)
Assigned to: CPU Architecture:Any

[13 Oct 2009 20:00] Lester Tarranza
Description:
As i was running a query for a project i encountered this error:

Error Number: 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 '`INTERVAL` 7 DAY) <= date_added ) AS member_count FROM (`membership`) ORDER BY `' at line 1

SELECT `membership`.`name`, (SELECT COUNT(*) FROM members WHERE members.membership_id=membership.id AND DATE_SUB(CURDATE(), `INTERVAL` 7 DAY) <= date_added ) AS member_count FROM (`membership`) ORDER BY `id`

Im using PHPMyAdmin to try the results. I used the same query on phpmyadmin:
SELECT membership.name, (

SELECT COUNT( * )
FROM members
WHERE members.membership_id = membership.id
AND DATE_SUB( CURDATE( ) , INTERVAL 7
DAY ) <= date_added
) AS member_count
FROM membership

It returned no error but as i ran the site it returned the above error.
Im using CodeIgniter for my site.

Other details:

# Server version: 5.0.81-community
# Protocol version: 10
# Server: Localhost via UNIX socket

phpMyAdmin - 2.11.9.5
* MySQL client version: 4.1.22
* Used PHP extensions: mysql

How to repeat:
SELECT membership.name, (SELECT COUNT(*) FROM members WHERE members.membership_id=membership.id AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= date_added ) AS member_count FROM membership
[13 Oct 2009 20:48] MySQL Verification Team
If I understood what you wrote with PhPMyAdmin returns not errors only with your application?.
[14 Oct 2009 3:01] Lester Tarranza
I just got it right..
It was not mySQL but it was the application's problem.
You were right Miguel. Thanks!

And sorry for that.