日期:2014-05-17 浏览次数:20416 次
select * from teacher a where id in (select teacherid from student group by teacherid having count(1)>=2)
------解决方案--------------------
;WITH c1 AS ( select t.id from teacher t LEFT JOIN student s ON t.id=s.teacherid GROUP BY t.id HAVING COUNT(t.id)>2 ) SELECT t.* FROM c1 JOIN teacher t ON c1.id = t.id