gpt4 book ai didi

MySQL 子查询错误 : SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'id'

转载 作者:行者123 更新时间:2023-11-29 00:46:32 29 4
gpt4 key购买 nike

我正在努力让以下 MySQL 语句正常工作。

SELECT ItemGroup.users_id,ItemGroup.comments_id,ItemGroup.uploads_id,ItemGroup.posts_id, 
Comment.id,Comment.uploads_id,
CommentUpload.id,
Upload.id,
Post.id
FROM items AS ItemGroup
LEFT JOIN (
SELECT Comment.id, Comment.uploads_id, CommentUpload.id, CommentUpload.uuid
FROM comments As Comment
INNER JOIN (
SELECT CommentUpload.id, CommentUpload.uuid
FROM uploads AS CommentUpload
) CommentUpload ON CommentUpload.id = Comment.uploads_id
GROUP BY Comment.uploads_id
) Comment ON Comment.id = ItemGroup.comments_id
LEFT JOIN (
SELECT Upload.id
FROM uploads AS Upload
) Upload ON Upload.id = ItemGroup.uploads_id
LEFT JOIN (
SELECT Post.id
FROM posts AS Post
) Post ON Post.id = ItemGroup.posts_id
WHERE ItemGroup.users_id = {$__cakeID__$}
AND (
Comment.id IS NOT NULL
OR Upload.id IS NOT NULL
OR Post.id IS NOT NULL
)
LIMIT 0 , 300

我试图找到与评论相关的上传,但它抛出 SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'id'。

我确定这是小事,但我就是找不到我做错了什么,我真的很感激能得到一些帮助。

感谢您的宝贵时间!

亚历克斯

最佳答案

你不能用相同的别名命名两个表 FROM comments As CommentGROUP BY Comment.uploads_id) Comment,使用 Comment_AComment_B 例如。

关于MySQL 子查询错误 : SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'id' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10335758/

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