0% found this document useful (0 votes)
8 views2 pages

SQL JOIN Queries and Examples

The document provides SQL JOIN queries for two tasks involving data retrieval from Products, Suppliers, Orders, Customers, Employees, and Projects. It includes various types of joins such as INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL JOIN, along with filtering and ordering results. The queries demonstrate how to extract specific fields and conditions from relational databases.

Uploaded by

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

SQL JOIN Queries and Examples

The document provides SQL JOIN queries for two tasks involving data retrieval from Products, Suppliers, Orders, Customers, Employees, and Projects. It includes various types of joins such as INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL JOIN, along with filtering and ordering results. The queries demonstrate how to extract specific fields and conditions from relational databases.

Uploaded by

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

LAB 9 – (SQL - JOIN)

Task- MODEL ANSWER


TASK 1
1) SELECT ProductName, CompanyName
FROM Products INNER JOIN Suppliers
ON [Link] = [Link];

OR

SELECT ProductName, CompanyName


FROM Products , Suppliers
WHERE [Link] = [Link];

2) SELECT DISTINCT CompanyName, OrderDate


FROM Orders INNER JOIN Customers
ON [Link] = [Link]
WHERE OrderDate > '1/1/95'
ORDER BY orderdate desc;

3) SELECT CompanyName, OrderDate


FROM Orders RIGHT OUTER JOIN Customers
ON [Link] = [Link];

OR

SELECT CompanyName, OrderDate


FROM CUSTOMERS LEFT OUTER JOIN ORDERS
ON [Link] = [Link];

4) SELECT *
FROM customers
WHERE customerId NOT IN(SELECT customerId FROM orders;

5) SELECT [Link]
FROM products, Suppliers
WHERE suppliers. SupplierID = [Link]
AND [Link] IN ('UK','USA')
TASK 2
1) SELECT [Link], [Link]
From Employee E , Project P
WHERE P.employee_id = E. emp_ID
ORDER BY [Link]

OR

SELECT [Link], [Link]


From Employee E inner join Project P
On P.employee_id = E. emp_ID
ORDER BY [Link]

2) SELECT [Link], [Link]


From Employee E Left join Project P
On P.employee_id = E. emp_ID
Order by [Link]

3) SELECT [Link]
From Employee E right join Project P
On P.employee_id = E. emp_ID
Order by [Link]

4) SELECT [Link], [Link]


From Employee E full join Project P
On P.employee_id = E. emp_ID

5) SELECT firstName, max(salary) as Max_salary


From Employee

You might also like