登录

用from的方法查找每个栏目下的最新商品,为什么查找出来的结果不正确

用from的方法查找每个栏目下的最新商品,为什么查找出来的结果不正确  

select goods_id,cat_id,goods_name from (select * from goods where 1 order by cat_id asc,goods_id desc)as tep group by cat_id;

# MySQL
P粉441358353 P粉441358353 597 天前 535 次浏览

全部回复(2) 我要回复

  • 雪漫雨悠

    雪漫雨悠2022-08-09 15:47:37

    分组-》排序-》取最新

    回复
    0
  • P粉441358353

    你好,我想请问一下为什么我写的和老师讲的一样,但是中间的from子句没有起到作用呢,取到的最新的goods_id还是没排序之前每个栏目第一个接触的值

    P粉441358353 · 2022-08-09 20:38:05
  • 取消 回复 发送