27,580
社区成员
发帖
与我相关
我的任务
分享
select p.product_id,max(i.ImagesPath)
from teapp p left join Base_ProductInfo_Images i on p.Product_id=i.Product_Id
group by product_id
--没有说怎么取一条,就随便吧
select distinct(p.product_id,i.ImagesPath) from teapp as p,Base_ProductInfo_Images as i where p.Product_id=i.Product_Id
select p.product_id,max(i.ImagesPath) ImagesPath
from teapp as p,Base_ProductInfo_Images as i
where p.Product_id=i.Product_Id group by product_id
你是想怎么匹配? 你这样就等于没加distinct.
如果你只想要product_id那就去掉ImagesPath,如果你想得到分组数据的话就得用group by.