【发布时间】:2020-12-08 17:28:53
【问题描述】:
我有几个表(表、教师、部门、学科等)。教师包含名称字段。所有其他人都有主键和外键。每个学院都有一些系,系中有教师,每个教师都有自己的职位,每个学科都有自己的类型,讲座,实习等。所以我有搜索的院系名称^strong text - s.name = '数据库' 或 s.name = 'C' 和 l.type = 'Lecture' - t.post ='讲解员' 下面是一个使用 INTERSECT 的示例查询,但我需要一个在 MySQL 中工作的查询。 我曾尝试使用 INNER JOIN,但它显示字段列表中的“Coulmn“名称”不明确。
select f.name
from faculty f, subject s, department d, teacher t, lecture l
where f.facpk=d.facfk and d.deppk=t.depfk and t.tchpk=l.tchfk and l.sbjfk=s.sbjpk and s.name = 'Data bases' or s.name = 'C' and l.type = 'Lecture'
intersect
select f.name
from faculty f, teacher t, department d
where f.facpk=d.facfk and d.deppk=t.depfk and t.post ='Docent';
【问题讨论】:
-
学习使用正确的、明确的、标准的、可读的
JOIN语法。