我有2个表INVENTORY
和PRODUCTS
,我想要选择INVENTORY
的一些列和PRODUCTS
中的一列。我写道:
SELECT INVENTORY.product, INVENTORY.version, PRODUCTS.customer
FROM INVENTORY
INNER JOIN PRODUCTS ON
INVENTORY.product = PRODUCTS.product AND INVENTORY.version= PRODUCTS.version
我得到了相同记录的多次..我是如何解决的?
答案 0 :(得分:0)
简单分明或分组:
SELECT DISTINCT INVENTORY.product, INVENTORY.version, PRODUCTS.customer
FROM INVENTORY
INNER JOIN PRODUCTS ON
INVENTORY.product = PRODUCTS.product AND INVENTORY.version= PRODUCTS.version
或者:
SELECT INVENTORY.product, INVENTORY.version, PRODUCTS.customer
FROM INVENTORY
INNER JOIN PRODUCTS ON
INVENTORY.product = PRODUCTS.product AND INVENTORY.version= PRODUCTS.version
GROUP BY INVENTORY.product, INVENTORY.version, PRODUCTS.customer