主表:Products
ID    ProductName

1     上衣

2     短裤

3     帽子

 

外键表:ProdutImage

ID    ProductID   ProductImage

1     1                上衣图片一

2     1                上衣图片二

3     2                 短裤图片一

4     2                 短裤图片二

SELECT *
FROM [SELECT Products.*, (select max(ID) from productImage where ProductID = Products.ID) AS MaxImageID
FROM Products]. AS TA, ProductImage
WHERE ProductImage.ID=TA.MaxImageID;

相关文章:

  • 2018-11-10
  • 2021-06-27
  • 2021-04-14
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-10-23
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案