Docsity

SQL Join Clauses Activity, Lab Reports of Database Programming

Toggle sidebar
bg1
Group Members:
______________________ _______________________
______________________ _______________________
Section: ________________
Laboratory Exercise (SQL Join Clauses)
Objectives:
At the end of the exercise, the students should be able to:
1. use different SQL join clauses.
Procedures:
In this laboratory exercise, we will use the tblCustomers and tblItems_Ordered tables in testDB
database.
Using SQL Joins
Table 1 tblCustomers
Angeline T. Respondo
Jhea Mae B. Wenceslao
Jeleme P. Ucab
Renalyn Salinay
BSIT-2E
pf3
pf4
pf5

Partial preview of the text

Download SQL Join Clauses Activity and more Lab Reports Database Programming in PDF only on Docsity!

Group Members:

______________________ _______________________

______________________ _______________________

Section: ________________

Laboratory Exercise ( SQL Join Clauses)

Objectives:

At the end of the exercise, the students should be able to:

  1. use different SQL join clauses.

Procedures:

In this laboratory exercise, we will use the tblCustomers and tblItems_Ordered tables in testDB

database.

Using SQL Joins Table 1 tblCustomers

Table 2 tblItems_Ordered

  1. Open a New Query editor to combine the two tables using the INNER JOIN as follows: SELECT tblCustomers.CustomerID, tblCustomers.FirstName, tblCustomers.LastName, tblItems_Ordered.Item, tblItems_Ordered.Quantity FROM tblCustomers INNER JOIN tblItems_Ordered ON tblCustomers.CustomerID = tblItems_Ordered.CustomerID
  2. The SQL above would produce the following^ result: Table 3 INNER JOIN query result

Observe what happens when two tables are being joined using the LEFT JOIN clause.

  1. Considering the two tables above (tblCustomers and tblItems_Ordered), what do you think will happen to the information on the first table if combined to the second table? Answer:
  2. What will happen to the customers who doesn’t have items ordered? Answer:
  3. What will happen to the items which wasn’t ordered? Answer:

Observe what happens when two tables are being joined using the RIGHT JOIN clause.

  1. Considering the two tables above (tblCustomers and tblItems_Ordered), what do you think will happen to the information on the second table if combined to the first table? Answer:
  2. What will happen to the customers who doesn’t have items ordered? Answer:
  3. What will happen to the items which wasn’t ordered? Answer:
  4. This time use the RIGHT JOIN in combining two tables above. Copy the SQL below: SELECT tblCustomers.CustomerID, tblCustomers.FirstName, tblCustomers.LastName, tblItems_Ordered.Item, tblItems_Ordered.Quantity FROM tblCustomers RIGHT JOIN tblItems_Ordered ON tblCustomers.CustomerID = tblItems_Ordered.CustomerID
  5. See results below: Table 5 RIGHT JOIN query result
  6. Use the query below to join two tables using the FULL JOIN. SELECT tblCustomers.CustomerID, tblCustomers.FirstName, tblCustomers.LastName, tblItems_Ordered.Item, tblItems_Ordered.Quantity FROM tblCustomers FULL JOIN tblItems_Ordered ON tblCustomers.CustomerID = tblItems_Ordered.CustomerID
  7. See results on the following table.