直接上代码:

1、group_concat

select SUBSTRING_INDEX(group_concat(id order by id desc),',',2) id from content c
where  c.grouperid in (1,2)
GROUP BY c.grouperid in (1,2);

mysql通过分组条件,取得分个条件中的最后一条记录。

 

 2、max

select max(id) as id from content where grouperid in (1,2) 
group by grouperid

mysql通过分组条件,取得分个条件中的最后一条记录。

 

有了id,那么下面就好办了, 自由发挥。

 

相关文章:

  • 2022-02-06
  • 2022-01-01
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2021-06-13
  • 2021-06-25
  • 2022-01-19
  • 2021-05-20
  • 2022-12-23
  • 2022-01-09
相关资源
相似解决方案