2
有一张名为teachers
的表格,其中列有teacher_id
,role_code
,visit_tutor
和class_code
列的教师的详细信息。如果role_code
是'CT'
和visit_tutor
是null
,则教师是班级的正式教师。如果visit_tutor
不是null
,他是班级的访问老师。如何使用双方的值范围自行连接表格?
如何获得的teacher_id
的老师谁是类的普通教师与class_code
'AA'
和来访班老师class_code
'BB'
的名单?
,因为第一个子查询返回多行下面的代码是抛出一个错误:
select * from teachers where (
select teacher_id from teachers t1 where t1.role_code='CT' and t1.class_code='AA'
) in (
select teacher_id from teachers t2 where t2.visit_tutor is not null and t2.class_code='BB'
);