MySQL 查询仅适用于某些版本

发布于 2024-11-09 11:51:28 字数 1020 浏览 0 评论 0原文

我有以下查询,

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
     ABS(DistanceTable.Distance - DistanceTable.TodaysDistance) <= 7
   ORDER BY
     ABS(DistanceTable.Distance - DistanceTable.TodaysDistance)
   LIMIT 0, 10;

它加载我的联系人列表表的生日,并显示我的联系人列表中接下来 10 个即将到来的生日。我的开发服务器是MySQL 5.0.51a,生产服务器是5.1.57,有没有可能是版本问题?

编辑 我确实在本地 PC 上模拟了完全相同的环境(相同的 PHP 版本、相同的 MySQL 版本,甚至将所有内容安装在运行 Debian Lenny 的虚拟机上,就像服务器一样,并且我一直在服务器,而在本地计算机上工作就像一个魅力)

我做的另一件事是在服务器的 PhpMyAdmin 工具上测试查询,它在那里工作正常,所以我猜测这是 PHP 进程的凭据问题,有什么想法吗?

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
     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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月依秋水 2024-11-16 11:51:28

请在此处查看 MySQL 错误代码: http://dev.mysql .com/doc/refman/5.0/en/error-messages-server.html

确保您在开发服务器和生产服务器上具有相同的访问权限。您的错误代码对应于:

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

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'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文