SELECT A.*,IFNULL(B.GuestName,'') AS GuestName,ec.ContractNo,ec.Id as ContractId,IFNULL(C.SName,'') AS SchoolName,IFNULL(D.ClassName,'') AS ClassName,IFNULL(T.TeacherName,'') AS TeacherName
SELECT A.*,IFNULL(B.GuestName,'') AS GuestName,ec.ContractNo,ec.Id as ContractId,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
,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
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_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 rb_class AS D ON A.ClassId=D.ClassId
LEFT JOIN rb_school AS C ON D.School_Id=C.SId
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)
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)