Inner Join


SQL Server Query

            
SELECT P.ProductName, S.CompanyName AS SupplierName, C.CategoryName, P.UnitPrice  
FROM Products P
INNER JOIN Suppliers S ON P.SupplierID = S.SupplierID
INNER JOIN Categories C ON P.CategoryID = C.CategoryID;

Create SQL query with SqlQueryBuilder

            
var (sql, parameters) = new SqlQueryBuilder()  
.Select()
.Column("P.ProductName", "ProductName")
.Column("S.CompanyName", "SupplierName")
.Column("C.CategoryName", "CategoryName")
.Column("P.UnitPrice", "UnitPrice")
.From("Products", "P")
.Join(new List<IJoin>()
{
new INNERJOIN().TableName("Suppliers","S")
.On(new Column("P.SupplierID").Equale(new Column("S.SupplierID"))),
new INNERJOIN().TableName("Categories","C")
.On(new Column("P.CategoryID").Equale(new Column("C.CategoryID")))
})
.Build();

Query build by SqlQueryBuilder

            
SELECT P.ProductName AS ProductName,
       S.CompanyName AS SupplierName,
       C.CategoryName AS CategoryName,
       P.UnitPrice AS UnitPrice
FROM Products AS P
     INNER JOIN
     Suppliers AS S
     ON P.SupplierID = S.SupplierID
     INNER JOIN
     Categories AS C
     ON P.CategoryID = C.CategoryID;


            
        

Parameters (If used)

Name Value

Query Results:

  ProductName SupplierName CategoryName UnitPrice
1 Chai Exotic Liquids Beverages 18.0000
2 Chang Exotic Liquids Beverages 19.0000
3 Aniseed Syrup Exotic Liquids Condiments 10.0000
4 Chef Anton's Cajun Seasoning New Orleans Cajun Delights Condiments 22.0000
5 Chef Anton's Gumbo Mix New Orleans Cajun Delights Condiments 21.3500
6 Grandma's Boysenberry Spread Grandma Kelly's Homestead Condiments 25.0000
7 Uncle Bob's Organic Dried Pears Grandma Kelly's Homestead Produce 30.0000
8 Northwoods Cranberry Sauce Grandma Kelly's Homestead Condiments 40.0000
9 Mishi Kobe Niku Tokyo Traders Meat/Poultry 97.0000
10 Ikura Tokyo Traders Seafood 31.0000
11 Queso Cabrales Cooperativa de Quesos 'Las Cabras' Dairy Products 21.0000
12 Queso Manchego La Pastora Cooperativa de Quesos 'Las Cabras' Dairy Products 38.0000
13 Konbu Mayumi's Seafood 6.0000
14 Tofu Mayumi's Produce 23.2500
15 Genen Shouyu Mayumi's Condiments 15.5000
16 Pavlova Pavlova, Ltd. Confections 17.4500
17 Alice Mutton Pavlova, Ltd. Meat/Poultry 39.0000
18 Carnarvon Tigers Pavlova, Ltd. Seafood 62.5000
19 Teatime Chocolate Biscuits Specialty Biscuits, Ltd. Confections 9.2000
20 Sir Rodney's Marmalade Specialty Biscuits, Ltd. Confections 81.0000
21 Sir Rodney's Scones Specialty Biscuits, Ltd. Confections 10.0000
22 Gustaf's Knäckebröd PB Knäckebröd AB Grains/Cereals 21.0000
23 Tunnbröd PB Knäckebröd AB Grains/Cereals 9.0000
24 Guaraná Fantástica Refrescos Americanas LTDA Beverages 4.5000
25 NuNuCa Nuß-Nougat-Creme Heli Süßwaren GmbH & Co. KG Confections 14.0000
26 Gumbär Gummibärchen Heli Süßwaren GmbH & Co. KG Confections 31.2300
27 Schoggi Schokolade Heli Süßwaren GmbH & Co. KG Confections 43.9000
28 Rössle Sauerkraut Plutzer Lebensmittelgroßmärkte AG Produce 45.6000
29 Thüringer Rostbratwurst Plutzer Lebensmittelgroßmärkte AG Meat/Poultry 123.7900
30 Nord-Ost Matjeshering Nord-Ost-Fisch Handelsgesellschaft mbH Seafood 25.8900
31 Gorgonzola Telino Formaggi Fortini s.r.l. Dairy Products 12.5000
32 Mascarpone Fabioli Formaggi Fortini s.r.l. Dairy Products 32.0000
33 Geitost Norske Meierier Dairy Products 2.5000
34 Sasquatch Ale Bigfoot Breweries Beverages 14.0000
35 Steeleye Stout Bigfoot Breweries Beverages 18.0000
36 Inlagd Sill Svensk Sjöföda AB Seafood 19.0000
37 Gravad lax Svensk Sjöföda AB Seafood 26.0000
38 Côte de Blaye Aux joyeux ecclésiastiques Beverages 263.5000
39 Chartreuse verte Aux joyeux ecclésiastiques Beverages 18.0000
40 Boston Crab Meat New England Seafood Cannery Seafood 18.4000
41 Jack's New England Clam Chowder New England Seafood Cannery Seafood 9.6500
42 Singaporean Hokkien Fried Mee Leka Trading Grains/Cereals 14.0000
43 Ipoh Coffee Leka Trading Beverages 46.0000
44 Gula Malacca Leka Trading Condiments 19.4500
45 Rogede sild Lyngbysild Seafood 9.5000
46 Spegesild Lyngbysild Seafood 12.0000
47 Zaanse koeken Zaanse Snoepfabriek Confections 9.5000
48 Chocolade Zaanse Snoepfabriek Confections 12.7500
49 Maxilaku Karkki Oy Confections 20.0000
50 Valkoinen suklaa Karkki Oy Confections 16.2500
51 Manjimup Dried Apples G'day, Mate Produce 53.0000
52 Filo Mix G'day, Mate Grains/Cereals 7.0000
53 Perth Pasties G'day, Mate Meat/Poultry 32.8000
54 Tourtière Ma Maison Meat/Poultry 7.4500
55 Pâté chinois Ma Maison Meat/Poultry 24.0000
56 Gnocchi di nonna Alice Pasta Buttini s.r.l. Grains/Cereals 38.0000
57 Ravioli Angelo Pasta Buttini s.r.l. Grains/Cereals 19.5000
58 Escargots de Bourgogne Escargots Nouveaux Seafood 13.2500
59 Raclette Courdavault Gai pâturage Dairy Products 55.0000
60 Camembert Pierrot Gai pâturage Dairy Products 34.0000
61 Sirop d'érable Forêts d'érables Condiments 28.5000
62 Tarte au sucre Forêts d'érables Confections 49.3000
63 Vegie-spread Pavlova, Ltd. Condiments 43.9000
64 Wimmers gute Semmelknödel Plutzer Lebensmittelgroßmärkte AG Grains/Cereals 33.2500
65 Louisiana Fiery Hot Pepper Sauce New Orleans Cajun Delights Condiments 21.0500
66 Louisiana Hot Spiced Okra New Orleans Cajun Delights Condiments 17.0000
67 Laughing Lumberjack Lager Bigfoot Breweries Beverages 14.0000
68 Scottish Longbreads Specialty Biscuits, Ltd. Confections 12.5000
69 Gudbrandsdalsost Norske Meierier Dairy Products 36.0000
70 Outback Lager Pavlova, Ltd. Beverages 15.0000
71 Flotemysost Norske Meierier Dairy Products 21.5000
72 Mozzarella di Giovanni Formaggi Fortini s.r.l. Dairy Products 34.8000
73 Röd Kaviar Svensk Sjöföda AB Seafood 15.0000
74 Longlife Tofu Tokyo Traders Produce 10.0000
75 Rhönbräu Klosterbier Plutzer Lebensmittelgroßmärkte AG Beverages 7.7500
76 Lakkalikööri Karkki Oy Beverages 18.0000
77 Original Frankfurter grüne Soße Plutzer Lebensmittelgroßmärkte AG Condiments 13.0000