0% found this document useful (0 votes)
61 views

Práctica Múltiple Join

The document contains examples of SQL queries using inner joins to retrieve information from related tables in a database. The queries include: 1) Retrieving the names of products from suppliers located in Manchester. 2) Retrieving the company names that supply the product "Chai". 3) Retrieving the order IDs for orders placed by the employee "Robert King". 4) Retrieving the name of employee 5 who placed orders for the customer "LILA-Supermercado". 5) Retrieving a complete list of customers who purchased products in the category "Seafood".

Uploaded by

ch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Práctica Múltiple Join

The document contains examples of SQL queries using inner joins to retrieve information from related tables in a database. The queries include: 1) Retrieving the names of products from suppliers located in Manchester. 2) Retrieving the company names that supply the product "Chai". 3) Retrieving the order IDs for orders placed by the employee "Robert King". 4) Retrieving the name of employee 5 who placed orders for the customer "LILA-Supermercado". 5) Retrieving a complete list of customers who purchased products in the category "Seafood".

Uploaded by

ch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

--===================================================================================================

--SQL PRACTICA: INNER JOIN


--===================================================================================================

--1
-----------------------------------------------------------------------------------------------------
--Nombre de los productos de los proveedores de Manchester
-----------------------------------------------------------------------------------------------------
SELECT Products.ProductName
FROM Products INNER JOIN Suppliers
ON Products.SupplierID = Suppliers.SupplierID
WHERE Suppliers.City = 'Manchester'
--(4)

--2
-----------------------------------------------------------------------------------------------------
--Nombre de las compañías que proveen el producto Chai
-----------------------------------------------------------------------------------------------------
SELECT Suppliers.CompanyName
FROM Products INNER JOIN Suppliers
ON Products.SupplierID = Suppliers.SupplierID
WHERE Products.ProductName = 'Chai'
--(1)

--3
-----------------------------------------------------------------------------------------------------
--Código de órdenes de compra generadas por el empleado Robert King
-----------------------------------------------------------------------------------------------------
SELECT Orders.OrderID
FROM Orders INNER JOIN Employees
ON Orders.EmployeeID = Employees.EmployeeID
WHERE Employees.LastName = 'King' AND Employees.FirstName = 'Robert'
--(72)

--4
-----------------------------------------------------------------------------------------------------
--Nombre y apellido de empleado 5 que generó órdenes de compra para el cliente LILA-Supermercado
-----------------------------------------------------------------------------------------------------
SELECT Employees.Firstname, Employees.Lastname
FROM Orders
INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID
WHERE Employees.EmployeeID = 5 AND Customers.CompanyName = 'LILA-Supermercado'
--(2)

--5
-----------------------------------------------------------------------------------------------------
-- Listado completo de clientes que compraron productos de categoría ‘Seafood’
-----------------------------------------------------------------------------------------------------
SELECT DISTINCT Customers.*
FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID
INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID
INNER JOIN Products ON [Order Details].ProductID = Products.ProductID
INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID
WHERE Categories.CategoryName = 'Seafood'
--(85)

You might also like