0% found this document useful (0 votes)
615 views4 pages

07 ANSI SQL Joins Hands-On Exercise 1

This document contains instructions and examples for 5 hands-on exercises on using different types of joins on database tables. The exercises involve writing queries to return various combinations of records from tables using inner, left outer, right outer, and full outer joins based on matching column values between tables. The goal is to help students learn how to use joins to retrieve related data from multiple tables.

Uploaded by

sappa vinay
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)
615 views4 pages

07 ANSI SQL Joins Hands-On Exercise 1

This document contains instructions and examples for 5 hands-on exercises on using different types of joins on database tables. The exercises involve writing queries to return various combinations of records from tables using inner, left outer, right outer, and full outer joins based on matching column values between tables. The goal is to help students learn how to use joins to retrieve related data from multiple tables.

Uploaded by

sappa vinay
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/ 4

Hands-on Exercise:

Joins
Version: Understanding ANSI SQL
Hands-on Exercise – Joins - Session No: 7

Table of Contents

SESSION 7: JOINS...............................................................................................................3

EXERCISE 1.........................................................................................................................3

EXERCISE 2.........................................................................................................................3

EXERCISE 3.........................................................................................................................3

EXERCISE 4.........................................................................................................................4

EXERCISE 5.........................................................................................................................4

Page 2

Cognizant Technology Solutions, All Rights Reserved


C3: Protected
Hands-on Exercise – Joins - Session No: 7

Session 7: Joins

Exercise 1

Hands-on Exercise Objective


After completing the hands-on exercises, you will be able to:
Use different types of joins on tables.

Problem Statement:
Write a query to display trainer_id and batch_id details in such a way that we get all
possible combinations of trainer IDs and batch IDs.
Hint: Use Trainer_Info and Batch_Info tables.

Deliverables Expected:
All combinations of trainer_id and batch_id are displayed.

Exercise 2

Problem Statement:
Write a query to display the records from all columns of table’s associate_status and
batch_info, wherever the batch_id in the two tables matches.

Deliverables Expected:
Records are displayed based on the condition specified.

Exercise 3

Problem Statement:
Write a query to display the associate IDs of the associates tagged to trainers and all the
trainer IDs irrespective of whether there are any associates tagged to them or not.
Hint: Use associate_status and trainer_info tables
Note: Use Right Outer Join

Deliverables Expected:

Page 3

Cognizant Technology Solutions, All Rights Reserved


C3: Protected
Hands-on Exercise – Joins - Session No: 7

Records are displayed based on the condition specified.

Exercise 4

Problem Statement:
Write a query to display the associate IDs of the associates tagged to trainers and all the
trainer IDs irrespective of whether there are any associates tagged to them or not. Hint:
Use associate_status and trainer_info tables.
Note: Use Left Outer Join

Deliverables Expected:
Records are displayed based on the condition specified.

Exercise 5

Problem Statement:
Write a query to display the associate IDs of all the associates and trainer IDs of all
trainers irrespective of whether any associate is mapped to a trainer ID and vice versa.
Hint: Use associate_status and trainer_info tables.
(NOTE: ANSI syntax for Full Outer Join is supported by SQL Server, Not Supported by
MySQL, Oracle, and Sybase)
Prerequisite: Add an associate_id which is not mapped to any trainer ID. Take care of the
alteration in constraints to the other tables in order to achieve this.

Deliverables Expected:
Records are displayed based on the condition specified.

Page 4

Cognizant Technology Solutions, All Rights Reserved


C3: Protected

You might also like