Professional Documents
Culture Documents
Query Processing Cont.: It1 - Database Management System
Query Processing Cont.: It1 - Database Management System
PROCESSING cont.
JOINS
• Lets you combine columns from two or more tables
into a single result set.
• To join data from two tables, you code the names
of two tables in the FROM clause along with the
JOIN keyword and ON phrase that specifies the join
condition.
Join condition. Indicates how the two tables should be
compared.
SYNTAX
SELECT select_list
FROM table_1
JOIN_TYPE table_2
ON join_condition
INNER JOIN
• Join only rows that satisfy the join condition.
Syntax:
SELECT select_list
FROM table_1
INNER JOIN table_2
ON join_condition
INNER JOIN
Student_tbl
Student_Number Student_Name Section_id
00-0001 A. Dela Cruz 01
00-0002 B. Cruz 02
00-0003 C. Reyes 04
Section_tbl
Section_id Section
01 A - 001
02 B - 001
03 C - 001
INNER JOIN
SELECT Student_Number, Student_Name, Section
FROM Student_tbl
INNER JOIN Section_tbl
ON Student_tbl.Section_id = Section_tbl.Section_id
Result
Student_Number Student_Name Section
00-0001 A. Dela Cruz A-001
00-0002 B. Cruz B-001
Section_tbl Course_tbl
Section_id Section Course_id Course
01 A - 001 1 BSIT
02 B - 001 2 BSEE
03 C - 001 3 BSIE
OUTER JOIN
• Returns all of the rows from one or both tables
involved in the join, regardless of whether the join
condition is true.
• Left Join. The result set includes all the rows from the first,
or left table.
• Right Join. The result set includes all the rows from the
second, or right table.
• Full Join. The result set includes all the rows from both
tables.
OUTER JOIN
THE END…