分组后按user_id 取时间最近的那一条 。 php思路也行。

SELECT
    a.id,
    a.order_type,
    a.user_id,
    GROUP_CONCAT(b.star_id) AS starIdStr,
    GROUP_CONCAT(c.weibo_user_id) AS weiboIdStr,
    sum(order_amount) AS sumPrice,
  a.order_time
FROM
    tb_order_info AS a
INNER JOIN tb_order_star AS b
INNER JOIN tb_star AS c
WHERE
    (
        a.id = b.order_id
        AND b.star_id = c.id
    )
group by a.id
order by  a.order_time desc

![clipboard.png](/img/bVYT72)

https://img3.mukewang.com/5c8f5c89000127fc07250253.jpg

https://img1.mukewang.com/5c8f5c8b0001ef8407260226.jpg

分组后按user_id 取时间最近的那一条 。
怎么取 求大神 ,php思路也行。

慕无忌1623718
浏览 509回答 4
4回答

扬帆大鱼

select id,max(time) from 表 group BY id
打开App,查看更多内容
随时随地看视频慕课网APP