I have to pull data from these tables
**PRODUCT** **LOOKUP_CATEGORY**
ID ProductName ID Category
1 Memory1 1 Product Type
2 Memory2 2 DIMM Type
3 Headset1 3 Color
4 Headset2 4 Speed
5 Keyboard1 5 Form Factor
6 Keyboard2
**LOOKUP**
ID CategoryID Value
1 1 DRAM
2 1 Keyboard
3 1 Headset
4 2 Buffered
5 2 Unbuffered
6 3 Red
7 3 White
8 3 Yellow
9 4 2000Mhz
10 4 2300Mhz
11 4 2600Mhz
12 5 DIMM
13 5 SODIMM
14 5 Earbud
15 5 On-Ear
**PRODUCT_FEATURES**
ID ProductID LookupID
1 1 1
2 1 4
3 1 10
4 1 12
5 2 1
6 2 5
7 2 9
8 2 13
9 3 3
10 3 7
11 3 15
12 4 3
13 4 6
14 4 14
15 5 2
16 5 7
17 6 2
18 6 8
I would like to get the result set like this
ProductName Type DIMMType Color Speed FormFactor
Memory1 DRAM Buffered NULL 2300Mhz DIMM
Memory2 DRAM Unbuffered NULL 2000Mhz SODIMM
Headset1 Headset NULL White NULL On-Ear
Headset2 Headset NULL Red NULL Earbud
Keyboard1 Keyboard NULL White NULL NULL
Keyboard2 Keyboard NULL Yellow NULL NULL
Basically, I would like to be able to get all the products. How do I this without making function calls? My database is Microsoft SQL 2016
I have tried this, but it does not seem to work as expected because of those NULL values
Select p.ProductID, p.ProductNumber
, lType.Value AS ProductType, lDimm.Value AS DimmType, lSpeed.Value AS Speed, lColor.Value AS Color, lFactor.Value AS FormFactor
From PRODUCT p
Left Join PRODUCT_FEATURES xType On p.ProductID = xType.ProductID
Inner Join LOOKUP lType On xType.LookupID = lType.LookupID
Inner Join LOOKUP_CATEGORY lcType On lType.CategoryID = lcType.LookupCategoryID And lcType.Category = 'Product Type'
Left Join PRODUCT_FEATURES xDimm On p.ProductID = xDimm.ProductID
Inner Join LOOKUP lDimm On xDimm.LookupID = lDimm.LookupID
Inner Join LOOKUP_CATEGORY lcDimm On lDimm.CategoryID = lcDimm.LookupCategoryID And lcDimm.Category = 'DIMM Type'
Left Join PRODUCT_FEATURES xSpeed On p.ProductID = xSpeed.ProductID
Inner Join LOOKUP lSpeed On xSpeed.LookupID = lSpeed.LookupID
Inner Join LOOKUP_CATEGORY lcSpeed On lSpeed.CategoryID = lcSpeed.LookupCategoryID And lcSpeed.Category = 'Speed'
Left Join PRODUCT_FEATURES xColor On p.ProductID = xColor.ProductID
Inner Join LOOKUP lColor On xColor.LookupID = lColor.LookupID
Inner Join LOOKUP_CATEGORY lcColor On lColor.CategoryID = lcColor.LookupCategoryID And lcColor.Category = 'Color'
Left Join PRODUCT_FEATURES xFactor On p.ProductID = xFactor.ProductID
Inner Join LOOKUP lFactor On xFactor.LookupID = lFactor.LookupID
Inner Join LOOKUP_CATEGORY lcFactor On lFactor.CategoryID = lcFactor.LookupCategoryID And lcFactor.Category = 'Form Factor'