gpt4 book ai didi

MySQL 5 多重 JOIN 语法在 MySQL 4 中不起作用

转载 作者:行者123 更新时间:2023-11-29 05:45:42 26 4
gpt4 key购买 nike

当前的 SQL 查询在运行 MySQL 5.1.37 的 MAMP 1.8.4 上本地运行良好。

  SELECT 
EL.log_actions, EL.log_date, EL.log_value, EL.log_type,
EA.admins_name,
EU.users_name, EU.users_matric
FROM events_log EL
JOIN events_users EU
USING (users_id)
JOIN events_admins EA
USING (admins_id)
ORDER BY EL.log_id DESC
LIMIT 0, 10

但是,当我将这个查询带到运行 MySQL 4.1.22-standard 的生产服务器上时,出现了以下错误(无论条目中是否有数据)。

A Database Error Occurred

Error Number: 1054

Unknown column 'sceclub_exclaim2007.EU.admins_id' in 'on clause'

SELECT EL.log_actions, EL.log_date, EL.log_value, EL.log_type,
EA.admins_name, EU.users_name, EU.users_matric
FROM events_log EL
JOIN events_users EU USING (users_id)
JOIN events_admins EA USING (admins_id)
ORDER BY EL.log_id
DESC LIMIT 0, 20

这是基于CodeIgniter 1.7.2,生产和开发都在运行同一套数据库。

数据库表

events_users: users_id users_name users_credits 
users_matric users_redeem

events_admins: admins_id admins_email admins_name
admins_pass admins_date admins_modified admins_last_login

events_attendance: attendance_id users_id events_id

events_events: events_id events_name events_venue events_time
events_desc events_pass

events_log:log_id admins_id log_actions log_date log_value
users_id log_type

我是 MySQL 的新手,所以我不知道版本有任何差异或可能的原因,在此先感谢您!

尝试谷歌搜索 MySQL4 差异也无济于事。也尝试使用

  SELECT 
EL.log_actions, EL.log_date, EL.log_value, EL.log_type,
EA.admins_name,
EU.users_name, EU.users_matric
FROM events_log EL
JOIN events_users EU
where EL.users_id = EU.users_id
JOIN events_admins EA
USING EL.admins_id = EA.admins_id
ORDER BY EL.log_id DESC
LIMIT 0, 10

但是后来我在生产和开发中都报错了。

A Database Error Occurred

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 'JOIN events_admins EA USING EL.admins_id = EA.admins_id ORDER BY' at line 8

SELECT EL.log_actions, EL.log_date, EL.log_value, EL.log_type, EA.admins_name, EU.users_name, EU.users_matric FROM events_log EL JOIN events_users EU where EL.users_id = EU.users_id JOIN events_admins EA USING EL.admins_id = EA.admins_id ORDER BY EL.log_id DESC LIMIT 0, 20

如果您能给我一些资源,让我可以阅读更多关于 MySQL 4 语法的信息,以达到与使用 MySQL 5 语法相同的效果,请告诉我。

再次感谢!

最佳答案

 SELECT 
EL.log_actions, EL.log_date, EL.log_value, EL.log_type,
EA.admins_name,
EU.users_name, EU.users_matric
FROM events_log AS EL
JOIN events_users AS EU
ON EL.users_id = EU.users_id
JOIN events_admins EA
ON EL.admins_id = EA.admins_id
ORDER BY EL.log_id DESC
LIMIT 0, 10

关于MySQL 5 多重 JOIN 语法在 MySQL 4 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2484873/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com