gpt4 book ai didi

MYSQL - 涉及多个表的查询时遇到问题

转载 作者:行者123 更新时间:2023-11-29 07:28:58 24 4
gpt4 key购买 nike

我需要帮助编写一个查询来查找注册某门类(class)的学生姓名,该类(class)由撰写了一篇名为“X”的文章的教授教授

我有代码可以找到撰写这篇文章的教授,但我在连接表格以查找注册该教授教授的类(class)的学生姓名时遇到了问题。

SELECT first_name, last_name, title)
FROM intellectual_contributions as ic, ic_contributors as icc, stakeholders as s
WHERE title ="X"
and ic.ic_id=icc.ic_id
and icc.stakeholder_id=s.stakeholder_id

最佳答案

您需要更多INNER JOIN。另外,尝试使用 JOINed 语法。

SELECT aa.first_name, aa.last_name, cc.title
FROM stakeholders AS aa
INNER JOIN ic_contributors AS bb
ON aa.stakeholder_id = bb.stakeholder_id
INNER JOIN intellectual_contributions AS cc
ON bb.ic_id = cc.ic_id
INNER JOIN course_enrollments AS dd
ON aa.stakeholder_id = dd.stakeholder_id
WHERE cc.title = "X";

关于MYSQL - 涉及多个表的查询时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33445625/

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