
mysql
WorldInEye
虽千万人 吾往矣
展开
-
查询被选最多的课程的课程名(course、selectcourse)
select c.cname from course c where c.cid in( -- 被选最多的课程的cid SELECT sc.cid from selectcourse sc GROUP BY cid -- 继续筛选 having count(sid) >= all( select count(sid) from selectcourse sc GROUP BY cid原创 2018-01-18 20:38:56 · 8522 阅读 · 0 评论 -
查询从未被选得课程名和课时
select c.cname,c.ctimenumber from course c where c.cid not in ( select cid from selectcourse sc); select c.cname,c.ctimenumber from course c left outer join selectcourse sc on c.cid = sc.cid whe原创 2018-01-18 20:41:28 · 1914 阅读 · 0 评论 -
查询各科目选课人数(count+left join)
select ce.cname,count(se.cid) from course ce LEFT JOIN selectcourse se on se.cid = ce.cid group by ce.cid;count(*)将nulll同样计算在其中count(指定) 可以去除null值原创 2018-01-18 20:48:20 · 21659 阅读 · 1 评论