mysql连接两个字段并进行多表联查

SELECT
   u.openid,o.user_name,o.student_phone,o.order_id,o.price,o.payment,c.duration,o.course_num,t.courses_type,a.coach_name,concat_ws('-',o.created_at,o.over_time) as expire_time,c.is_field,o.class_surplus,o.state,o.created_at
FROM
   ox_courses_order o
   left JOIN ox_user u ON u.id = o.user_id
   left join ox_class_history h on h.order_id=o.order_id
   left join ox_courses c on c.id=o.course_id
   left join ox_staff s on s.id=h.couch_id
   left join ox_courses_type t on t.id=c.courses_type_id
   left join ox_coach_level a on a.id=o.couch_id
   GROUP BY o.order_id

你可能感兴趣的:(mysql)