SELECT A.*,B.CourseName,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead,E.SName AS SchoolName,R.RoomName,IFNULL(t.GuestNum,0) as OrderStudentCount
FROM rb_class AS A
LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
SELECT A.*,B.CourseName,D.TeacherName,IFNULL(D.TeacherHead,'') AS TeacherHead,E.SName AS SchoolName,R.RoomName
,IFNULL(t.GuestNum,0) AS OrderStudentCount
FROM rb_class AS A LEFT JOIN rb_course AS B ON A.CouseId=B.CourseId
LEFT JOIN rb_teacher AS D ON A.Teacher_Id=D.TId
LEFT JOIN rb_class_room AS R ON A.ClassRoomId=R.RoomId
LEFT JOIN rb_school AS E ON A.School_Id=E.SId
left join (SELECT ClassId, SUM(GuestNum) AS GuestNum FROM rb_order WHERE OrderState in (1,2) GROUP BY ClassId)t on A.ClassId = t.ClassId
LEFT JOIN (SELECT ClassId,SUM(GuestNum) AS GuestNum FROM rb_order WHERE OrderState IN (1,2) GROUP BY ClassId)t on A.ClassId = t.ClassId
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Status),0);
...
...
@@ -264,6 +264,11 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.CouseId),query.CouseId);
}
//课程分类编号
if(query.CateId>0)
{
builder.AppendFormat(" AND B.{0}={1} ",nameof(RB_Class_ViewModel.CateId),query.CateId);
}
if(query.Teacher_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_ViewModel.Teacher_Id),query.Teacher_Id);