MySQL 查询仅适用于某些版本
我有以下查询,
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请在此处查看 MySQL 错误代码: http://dev.mysql .com/doc/refman/5.0/en/error-messages-server.html
确保您在开发服务器和生产服务器上具有相同的访问权限。您的错误代码对应于:
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: