select   * FROM (
 SELECT @row_number := CASE WHEN  @customer_no = user_id THEN @row_number + 1 ELSE 1 END AS num,
     @customer_no := user_id AS user_id,
     id,
     update_time
 FROM expert_course,   (SELECT @row_number:=0, @customer_no:=0) AS temp
 ORDER BY user_id DESC
) AS a
WHERE a.num <= 2
ORDER BY update_time;

posted on 2020-04-30 16:21  微笑点燃希望  阅读(199)  评论(0编辑  收藏  举报
font=white