gpt4 book ai didi

mysql - 查询不会在本地主机上运行

转载 作者:行者123 更新时间:2023-11-29 17:01:22 25 4
gpt4 key购买 nike

我有一个查询,它使用联接从主数据库中的主表和用户数据库中提取数据。

SELECT 
`user_details`.`id` AS `masterid`,
`user_details`.`emailaddress`,
`user_details`.`is_login` as `userstate`,
`user_details`.`fullname` as fullname,
`user_details`.`securitytemplate`,
`user_details`.`registered`,
`user_details`.`isactive`,
`users`.`id` AS `userid`,
`users`.`profilepicture` AS `userpic`,
security.templatename
FROM
(SELECT * FROM `gs_master`.`user_details`
WHERE `gs_master`.`user_details`.`db_identifier`= 136) AS `user_details`
LEFT JOIN gs_db_136.`users`
ON `user_details`.`emailaddress` = `users`.`email`
JOIN gs_db_136.`security_templates` AS security
ON security.id = `gs_master`.`user_details`.securitytemplate
ORDER BY
fullname ASC

奇怪的是它在我的 Centos 机器上运行,但不会在我的本地主机上运行。我已经更新了数据库并且表都存在。如果我直接查询本地主机表,我会得到结果,所以我不太确定它可能是什么?我猜这一定与不同机器上允许的语法有关?

我得到的错误是:

#1054 - Unknown column 'gs_master.user_details.securitytemplate' in 'on clause'

非常感谢任何帮助。

最佳答案

这可能是您想要得到的:

SELECT 
`user_details`.`id` AS `masterid`,
`user_details`.`emailaddress`,
`user_details`.`is_login` as `userstate`,
`user_details`.`fullname` as fullname,
`user_details`.`securitytemplate`,
`user_details`.`registered`,
`user_details`.`isactive`,
`users`.`id` AS `userid`,
`users`.`profilepicture` AS `userpic`,
security.templatename
FROM
(SELECT * FROM `gs_master`.`user_details`
WHERE `gs_master`.`user_details`.`db_identifier`= 136) AS `user_details`
LEFT JOIN gs_db_136.`users`
ON `user_details`.`emailaddress` = `users`.`email`
JOIN gs_db_136.`security_templates` AS security
ON security.id = `user_details`.securitytemplate
ORDER BY
fullname ASC

关于mysql - 查询不会在本地主机上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52219726/

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