开发者

MySQL query working only on some versions

开发者 https://www.devze.com 2023-03-08 13:59 出处:网络
I have the following query SELECT * FROM ( ( SELECT DATEDIFF( birthdate,CONCAT(YEAR(birthdate), \'/1/1\') ) AS Distance,

I have the following query

SELECT *
FROM (
     (
       SELECT
         DATEDIFF( birthdate,  CONCAT(YEAR(birthdate), '/1/1') ) AS Distance,
         DATEDIFF( CURDATE(), CONCAT(YEAR(CURDATE()), '/1/1')) AS TodaysDistance,
         db.Contact.*
       FROM
         db.Contact
       WHERE
         db.Contact.id IN (
           SELECT
             db.addressbook.contactid
           FROM
             db.addressbook
           WHERE
             db.addressbook.ownerid = 9
       )
       ) AS DistanceTable
   )
   WHERE
    开发者_Python百科 ABS(DistanceTable.Distance - DistanceTable.TodaysDistance) <= 7
   ORDER BY
     ABS(DistanceTable.Distance - DistanceTable.TodaysDistance)
   LIMIT 0, 10;

It loads the birthdays of my contact list table and shows me the next 10 upcoming birthdays on my contact list. My development server is MySQL 5.0.51a and the production server is 5.1.57, is there any chance that is a version problem?

EDIT I did simulated the exact same environment on my local PC (same PHP version, same MySQL version and even installed all on my Virtual Machine running Debian Lenny like the server and I keep getting the same problem on the server, while on the local machine works like a charm)

Another thing I did was testing the query on the server's PhpMyAdmin tool and it works ok there, so Im guessing it's a problem with the credentials of the PHP process, any thoughts?


See MySQL error codes here: http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html

Make sure that you have the same access permissions on both your dev and production servers. Your error code corresponds to:

%s command denied to user '%s'@'%s' for table '%s'
0

精彩评论

暂无评论...
验证码 换一张
取 消