SELECT o.*,c.ClassName,c.ClassScrollType,t.TeacherName,t.TeacherIcon,IFNULL(course.CourseName,'') AS CourseName,c.OpenTime,IFNULL(course.ClassHours,0) AS ClassHours
SELECT o.*,c.ClassName,c.ClassScrollType,t.TeacherName,t.TeacherIcon,IFNULL(course.CourseName,'') AS CourseName,c.OpenTime,IFNULL(g.TotalHours,0) AS ClassHours
FROM RB_Order o
left join rb_order_guest g on o.OrderId = g.OrderId
LEFT JOIN rb_class c on o.ClassId = c.ClassId
LEFT JOIN rb_teacher t on c.Teacher_Id = t.TId
LEFT JOIN rb_course AS course ON (o.CourseId=course.CourseId AND o.CourseId>0 AND o.OrderType=1)