Inner Join
-- Deze wordt ook wel equijoin genoemd / testen van equality SELECT <kolom1>, <kolom2> FROM <tabel1>, <tabel2> WHERE <tabel1.sleutel1> = <tabel2.<sleutel2>of
SELECT <kolom1>, <kolom2> FROM <tabel1> INNER JOIN <tabel2> ON <tabel1.sleutel1> = <tabel2.sleutel2>
Selecteer alle productnamen, productprijzen en de bijbehorende leveranciersnaam
-- Oracle / MySQL / SQL Server SELECT Vendors.vend_name, Products.prod_name, Products.prod_price FROM Vendors INNER JOIN Products ON Vendors.vend_id = Products.vend_id;of
-- Oracle / MySQL / SQL Server SELECT Vendors.vend_name, Products.prod_name, Products.prod_price FROM Products INNER JOIN Vendors ON Products.vend_id = Vendors.vend_id;
vend_name | prod_name | prod_price |
Doll House Inc. | Fish bean bag toy | 3.49 |
Doll House Inc. | Bird bean bag toy | 3.49 |
Doll House Inc. | Rabbit bean bag toy | 3.49 |
Bears R Us | 8 inch teddy bear | 5.99 |
Bears R Us | 12 inch teddy bear | 8.99 |
Bears R Us | 18 inch teddy bear | 11.99 |
Doll House Inc. | Raggedy Ann | 4.99 |
Fun and Games | King doll | 9.49 |
Fun and Games | Queen doll | 9.49 |
SELECT Vendors.vend_name, Products.prod_name, Products.prod_price FROM Products, Vendors;
-- Oracle / MySQL / SQL Server SELECT Customers.cust_name AS KlantNaam, Customers.cust_contact AS KlantContact, Products.prod_name AS ProductNaam, Vendors.vend_name AS Leverancier FROM Customers INNER JOIN Orders ON Customers.cust_id = Orders.cust_id INNER JOIN OrderItems ON Orders.order_num = OrderItems.order_num INNER JOIN Products ON OrderItems.prod_id = Products.prod_id INNER JOIN Vendors ON Products.vend_id = Vendors.vend_id WHERE OrderItems.prod_id = 'RGAN01';
KlantNaam | KlantContact | ProductNaam | Leverancier |
Fun4All | Denise L. Stephens | Raggedy Ann | Doll House Inc. |
The Toy Store | Kim Howard | Raggedy Ann | Doll House Inc. |