gpt4 book ai didi

mysql - 如何将 2 个表连接到另一个表中

转载 作者:行者123 更新时间:2023-11-29 22:56:06 24 4
gpt4 key购买 nike

这是我的表格列表:

tblsection
tblgradelevel
tblteachers

我的tblsection包含:

Section_ID | GradeID | sectionname | TeacherID

我的问题是如何在 tblsection 中链接 GradeIDTeacherID

我在 tblsection 中的外键是:

Foreign key name   | Reference table            |  Column  | Reference Column
Section_GradeID | 'database','tblgradelevel' | GradeID | GradeID
Section_TeacherID |'database','tblteacher' | TeacherID| Teacher_ID

我使用了很多查询来执行此问题,但它不起作用。

这是我的查询:

"SELECT 
a.Section_ID AS ID,
a.Sectionname AS SName,
b.GradeLevel AS Level,
c.TeacherID as Teach
FROM tblsection
INNER JOIN tblGradelevel b ON a.GradeID = b.GradeID";

我该怎么做?

最佳答案

**The query will generate errors due to invalid alias for the table name tblsection **
Try below query:
SELECT
a.Section_ID AS ID,
a.Sectionname AS SName,
b.GradeLevel AS Level,
c.TeacherID as Teach
FROM tblsection a
INNER JOIN tblGradelevel b ON a.GradeID = b.GradeID
INNER JOIN tblteachers c ON a.TeacherID = c.TeacherID

关于mysql - 如何将 2 个表连接到另一个表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28714536/

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