SELECT A.*,IFNULL(B.GuestName,'') AS GuestName,IFNULL(C.ClassName,'') AS ClassName,C.ClassNo,IFNULL(D.CourseName,'') AS CourseName,IFNULL(E.RoomName,'') AS RoomName
,IFNULL(F.TeacherName,'') AS TeacherName,CONCAT(ct.StartTime,'~',ct.EndTime) as TimeBucket
FROM RB_Class_Check AS A
left join rb_class_time ct on ct.ClassTimeId = A.ClassTimeId
LEFT JOIN rb_order_guest AS B ON A.OrderGuestId=B.Id
LEFT JOIN rb_class AS C ON A.ClassId=C.ClassId
LEFT JOIN rb_course AS D ON C.CouseId=D.CourseId
LEFT JOIN rb_class_room AS E ON A.ClassRoomId=E.RoomId
LEFT JOIN rb_teacher AS F ON A.TeacherId=F.TId
WHERE 1=1 AND A.Status=0 ");
if(query!=null)
{
if(query.Group_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Check_ViewModel.Group_Id),query.Group_Id);
}
if(query.School_Id>=0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Check_ViewModel.School_Id),query.School_Id);
}
if(query.ClassId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Check_ViewModel.ClassId),query.ClassId);
}
if(query.CouseId>0)
{
builder.AppendFormat(" AND C.{0}={1} ",nameof(RB_Class_Check_ViewModel.CouseId),query.CouseId);
}
if(!string.IsNullOrEmpty(query.Q_ClassIds))
{
builder.AppendFormat(" AND A.{0} in({1}) ",nameof(RB_Class_Check_ViewModel.ClassId),query.Q_ClassIds);
}
if(query.OrderGuestId>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Class_Check_ViewModel.OrderGuestId),query.OrderGuestId);
}
if(!string.IsNullOrEmpty(query.GuestName))
{
builder.AppendFormat(" AND B.GuestName like @GuestName ");
SELECT A.*,IFNULL(B.GuestName,'') AS GuestName,IFNULL(C.SName,'') AS SchoolName,IFNULL(D.ClassName,'') AS ClassName,IFNULL(T.TeacherName,'') AS TeacherName
SELECT A.*,IFNULL(B.GuestName,'') AS GuestName,ec.ContractNo,IFNULL(C.SName,'') AS SchoolName,IFNULL(D.ClassName,'') AS ClassName,IFNULL(T.TeacherName,'') AS TeacherName
,IFNULL(E.EnterID,0) AS EnterID,IFNULL(F.CourseName,'') AS CourseName,D.ClassNo
FROM RB_Student_BackClass AS A LEFT JOIN rb_order_guest AS B ON A.GuestId=B.Id
left join rb_education_contract ec on B.Id = ec.GuestId and ec.Status <>4
LEFT JOIN rb_school AS C ON A.SchoolId=C.SId
LEFT JOIN rb_class AS D ON A.ClassId=D.ClassId
LEFT JOIN (SELECT account.Id,teac.TeacherName FROM rb_account AS account INNER JOIN rb_teacher AS teac ON account.AccountId=teac.TId AND account.AccountType=2)