复杂的左连接查询

查询A表的所有字段,还要查询和A表关联的B表的C字段的个数,条件是A.Fnum=B.Cnum

复杂的左连接查询_第1张图片

SQL语句:

select FCOURSEWARE_NAME,fid ,fcourseware_type ,ftime_long ,flanguages ,fowner ,fcontributor ,fon_line_time,stu.c,s.c,fstate

from COURSEWARE c left join (select count(1) as c,course_number from user_course_study_info where course_number is not null group by course_number ) stu 

on stu.course_number = c.fcourse_id left join (select count(1) as c,course_number from user_course_study_info where BROWSE_SCORE=100 and course_number is not null group by course_number) s

on s.course_number = c.fcourse_id

你可能感兴趣的:(复杂的左连接查询)