我想加入三个表productgroup
,businessgroup
,businessunit
。
这是我的疑问:
SELECT
`productgroup`.*, businessunit.*
FROM
`productgroup`
INNER JOIN `prodgroupbusinessunit`
ON (`productgroup`.`prodgroupid` = `prodgroupbusinessunit`.`prodgroupid`)
INNER JOIN businessunit
ON (businessunit.`businessunitid` = `prodgroupbusinessunit`.businessunit)
我使用了表的内部联接,上面的查询获取了所有记录但它获得了多个productgroupnames 。 我如何使查询显示productgroupname?
以下是我的表格的结构和数据:
productgroupid productgroupname
--------------------------------------------------------------------
1 tasty
2 creamy
3 lingering
4 watering
5 yummy
6 swallow
businessunitid businessunitname
--------------------------------------------------------------------
1 food
2 beverage
productgroupbusinessunitid productgroupid businessunitid brand
---------------------------------------------------------------------------------
1 1 1 brand1
2 1 1 brand1
3 2 1 brand2
4 3 1 brand3
5 4 1 brand4
6 1 2 brand5
7 2 2 brand6
8 5 2 brand7
9 6 1 brand8
10 6 2 brand9
---------------------------------------------------------------------------------