INNER JOIN “字段列表”中的未知列
我试图显示这些列中的信息,但它一直告诉我教授表中的first_name 列未知。有谁知道为什么? 请帮助我,我已经尝试了一切。 谢谢。
这是查询:
SELECT courses.name, sections.section_name, professors.first_name, professors.last_name, classrooms.room
FROM courses
INNER JOIN course_section ON sections.id = course_section.section_id
INNER JOIN professor_course ON professors.id = professor_course.professor_id
WHERE courses.id = 1;
I'm trying to display the information I have in these columns and it keeps telling me that the first_name column in my professors table is unknown. Does anyone know why?
Please help me, I've tried everything.
Thanks.
Here's the query:
SELECT courses.name, sections.section_name, professors.first_name, professors.last_name, classrooms.room
FROM courses
INNER JOIN course_section ON sections.id = course_section.section_id
INNER JOIN professor_course ON professors.id = professor_course.professor_id
WHERE courses.id = 1;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
该错误是因为您没有在任何from 或join 中包含部分。 教授也会发生同样的事情。
就我个人而言,我更喜欢这种情况下隐含内部联接的可读性。 DBA 可能不同意,但作为一名程序员,我发现这更容易弄清楚发生了什么。
不知道您的数据库结构,您可能可以通过更少的表连接来获得您正在寻找的内容。
The error is because you haven't included sections in any from or join. You have the same thing going on with professors.
Personally, I prefer the readability of implied inner joins in this situation. A DBA may disagree, but as a programmer I find this easier to figure out what's going on.
Not knowing your DB structure, you can probably get what you are looking for with less table joins.
您没有在 FROM 子句中加入
professors
表,您只有professor_course
。You're not joining the
professors
table in your FROM clause, you only haveprofessor_course
.重新检查数据库,您可能拼错了其中的列。
Recheck the database, you probably misspelled the column in there.
你有完全错误的查询..
没有这样的表
因为你从不同的表(
SELECT
子句)中进行选择,并且FROM
或JOIN
子句中在编写上述条件之前,您必须包含表
sections
,同样的事情,
在编写上述条件之前,您必须包含表
professors
,我认为您的查询应该是
注意:最好对表使用 别名
ALL D BEST
u have completely wrong Query..
as u r selecting from different tables(
SELECT
clause) and there is no such table onFROM
orJOIN
clausein
u must include table
sections
before writing above conditionsame thing for
u must include table
professors
before writing above conditioni think your Query should be
Note: better to use alias for tables
ALL D BEST