我有一个复杂的查询来显示不同商店的一些产品。我试图排除一些结果,但我无法做到。我的桌子看起来像这样:
ProName ProColor ProSize ShopName ShopAddress
Pro1 col1 10 Shop1 Address1
Pro2 col2 12 Shop2 Address2
Pro3 col3 12 Shop1 Address1
Pro3 col3 12 Shop2 Address2
查询(必不可少):
SELECT Products.ProId, Products.ProName, Products.ProColor, Products.ProSize, Shop.ShopId, Shop.ShopName, Shop.ShopAddress Stock.StockId, Stock.StoProId, Stock.StoShopId
FROM Products, Shop, Stock
WHERE ((Stock.StoProId = Products.ProId) AND (Stock.StoShopId = Shop.ShopId))
上表有4列。当产品和颜色和尺寸相等时,但我在不同的商店有产品,我只想在表格中显示一次(无论ShopName显示,但只有一个):
ProName ProColor ProSize ShopName ShopAddress
Pro1 col1 10 Shop1 Address1
Pro2 col2 12 Shop2 Address2
Pro3 col3 12 Shop1 Address1
拜托,有人可以帮助我吗?
答案 0 :(得分:1)
请求结尾处的简单GROUP BY子句应该可以正常工作
GROUP BY Products.ProColor, Products.ProSize
但这是一个奇怪的问题。