关联查询可以解决你的问题,用到group by分组、limit 1即可
每个类型下最新的商品
每个类型,就是每个商品种类
假设商品表表名为A,种类表为B假设商品种类表的主键为type_id
group by B.type_id
关联查询:两张表肯定有关系,没猜错的话就是商品的种类id
sql语句为:
select
A.* from
A left join B on a.product_type_id = B.type_id
group by B.type_id
order by A.id desc limit 1
自己组织一下,不难的
select * from tabel_name where bianhao='01' order by id desc limit 0,1或者 select max(id), bianhao, value from table_name where bianhao='01'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)