Thinkphp 代码: public function myorder(){ $obj = M(); $sql = "select GROUP_CONCAT(oc.courseList_id ORDER BY oc.courseList_id DESC) AS courseList,o.order_id,o.user_id,o.user_name,o.number,o.orderTime,o.status,o.amount,oc.courseList_id from tb_order as o inner join tb_order_courselist as oc on o.order_id=oc.order_id where o.user_id=".$_SESSION['user_id']." group by o.order_id order by o.order_id desc"; $orderData = $obj->query($sql); foreach ($orderData as $value){ $sql_list = "select * from tb_order_courseList where courseList_id in(".$value['courseList'].")"; $course_list = $obj->query($sql_list);