SELECT thumb_image,img_type,goods_id from ecs_goods_gc_image WHERE goods_id =379 order by up_date desc 得到数据如图片
这不是我想最终要的效果,我想只获取到第一条数据 其他的不要 所以我用了groug分组 但是得到的数据不准确啊 为什么 求大神帮我改一下语句SELECT thumb_image,img_type,goods_id from ecs_goods_gc_image WHERE goods_id =379 group BY goods_id order by up_date desc
这不是我想最终要的效果,我想只获取到第一条数据 其他的不要 所以我用了groug分组 但是得到的数据不准确啊 为什么 求大神帮我改一下语句SELECT thumb_image,img_type,goods_id from ecs_goods_gc_image WHERE goods_id =379 group BY goods_id order by up_date desc
怎么会不行?
你的SQL语句
SELECT thumb_image,img_type,goods_id from ecs_goods_gc_image WHERE goods_id =379 group BY goods_id order by up_date desc改成一下SQL语句
Select 【不知道你表有没有id】,thumb_image,img_type,goods_id
from ecs_goods_gc_image AS a
Where (not) exists(Select 1 From ecs_goods_gc_image As b Where a.goods_id=b.goods_id and a.id < b.id)