Week 5
Joining
Objective: of this lab Manual is to get familiar with join in
databases.
Background:
The SQL Joins clause
is used to combine records from two or more tables in a database. A JOIN is a
means for combining fields from two tables by using values common to each.
Pre-lab: previous labs.
Assessment
tools:
The assessment is according to the student participation in
the lab if the student solves the exercise, he will get the participation mark
for this lab.
Joining
You can use the Student_Quiz_db for these queries
Inner Join
SELECT column_names FROM table1
INNER JOIN table2 ON table1.column_name = table2.column_name;
Fetch all data of
student_t and courses_t by using inner joining.
SELECT students.cms_id,students.name,students.email,students.mob_number,courses.name
FROM students
INNER JOIN courses ON
students.cms_id = courses.cms_id;
Fetch all data of
teacher_t and courses_t by using inner joining.
select teachers.t_cms_id,teachers.name,teachers.email,teachers.mob_number,courses.name
FROM teachers INNER JOIN courses ON teachers.t_cms_id=courses.t_cms_id
Fetch all data of
student_t , courses_t and student_t at a single time by using inner joinng .
select teachers.t_cms_id,teachers.name,teachers.email,teachers.mob_number,courses.name,students.name,students.email,students.mob_number
FROM ((courses INNER JOIN teachers ON
teachers.t_cms_id=courses.t_cms_id)INNER JOIN students ON
students.cms_id=courses.cms_id)
Fetch all data of
student_t and courses_t by using self joining .
SELECT
teachers.t_cms_id,teachers.name,teachers.email, teachers.mob_number,courses.name
FROM teachers,courses WHERE teachers.t_cms_id=courses.t_cms_id
Different Types of SQL Joins:
|
o wah g wah.....sawaad aa gya
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteo shut up yrR
DeleteThis comment has been removed by the author.
ReplyDeletenice pic dear
ReplyDeletePost a Comment