SlideShare a Scribd company logo
Swapnali Pawar GCEKarad
Database Lab
Swapnali Pawar
JOINS in SQL
1
 Oracle JOINS are used to retrieve data from multiple tables.
 JOIN clause combines rows from two or more tables.
 creates a set of rows in a temporary table
Joins
Swapnali Pawar GCEKarad
2
Types of SQL JOIN
❖ EQUI JOIN
● EQUI JOIN is a simple SQL join.
● Uses the equal sign(=) as the comparison operator for
the condition
● NON EQUI JOIN uses comparison operator other than
the equal sign.
● The operators uses like >, <, >=, <= with the
condition.
❖ NON EQUI JOIN
Swapnali Pawar GCEKarad
3
Types of SQL EQUI JOIN
❖ INNER JOIN
❖ OUTER JOIN
● Returns only matched rows from the
participating tables.
● Match happened only at the key record of
participating tables.
● Returns all rows from one table and
● Matching rows from the secondary table and
● Comparison columns should be equal in both
the tables.
Swapnali Pawar GCEKarad
4
List of SQL JOINS
• INNER JOIN
• LEFT JOIN OR LEFT OUTER JOIN
• RIGHT JOIN OR RIGHT OUTER JOIN
• FULL OUTER JOIN
• NATURAL JOIN
• CROSS JOIN
• SELF JOIN
Swapnali Pawar GCEKarad
5
• SQL EQUI JOIN performs a JOIN against equality or
matching columns values of the associated tables. An
equal sign (=) is used as comparison operator in the
where clause to refer equality.
• You may also perform EQUI JOIN by using JOIN keyword
followed by ON keyword and then specifying names of the
columns along with their associated tables to check equality
• Syntax :
SELECT column_list FROM table1, table2....
WHERE table1.column_name = table2.column_name;
• Example –
SELECT student.name, student.id, record.class, record.city
FROM student, record WHERE student.city = record.city;
1. EQUI JOIN
Swapnali Pawar GCEKarad
6
1. EQUI JOIN 2nd way
Syntax :
SELECT column_list FROM table1 JOIN
table2 ON (join_condition)
Example –
SELECT student.name, student.id,
record.class, record.city FROM student
JOIN record ON student.city =
record.city;
Swapnali Pawar GCEKarad
7
Swapnali Pawar GCEKarad
8
Select * from Record;
Select * from Student; SELECT student.name, student.id, record.class,
record.city
FROM Student
JOIN Record
ON Student.city = Record.city;
Equi Join Example
Swapnali Pawar GCEKarad
9
NON-EQUI JOIN
• Non-equi joins are joins whose join conditions use
conditional operators other than equals
• The SQL NON EQUI JOIN uses comparison operator
instead of the equal sign like >, <, >=, <= along with
conditions.
• Syntax:
SELECT * FROM table_name1, table_name2
WHERE
table_name1.column [> | < | >= | <= ]
table_name2.column
Swapnali Pawar GCEKarad
10
Swapnali Pawar GCEKarad
11
• A self join is a join in which a table is joined with itself
(Unary relationships), specially when the table has a
FOREIGN KEY which references its own PRIMARY KEY.
• To join a table itself means that each row of the table is
combined with itself and with every other row of the
table.
• The self join can be viewed as a join of two copies of the
same table.
self join
Swapnali Pawar GCEKarad
12
table_A
SELECT *
FROM table_A X, table_A Y
WHERE X.A=Y.A;
Output
table_A
Swapnali Pawar GCEKarad
13
INNER JOIN (simple join)
• It is the most common type of join. Oracle INNER JOINS return all rows
from multiple tables where the join condition is met.
• Syntax
SELECT columns FROM table1 INNER JOIN table2 ON table1.column =
table2.column;
Swapnali Pawar GCEKarad
14
LEFT OUTER JOIN
• Another type of join is called an Oracle LEFT OUTER JOIN. This type of join
returns all rows from the LEFT-hand table specified in the ON condition
and only those rows from the other table where the joined fields are equal (join
condition is met).
• Syntax
SELECT columns FROM table1 LEFT [OUTER] JOIN table2 ON
table1.column = table2.column;
• In some databases, the LEFT OUTER JOIN keywords are replaced with LEFT
JOIN.
• The Oracle LEFT OUTER JOIN would return the all records from table1 and
only those records from table2 that intersect with table1.
Swapnali Pawar GCEKarad
15
RIGHT OUTER JOIN
• Another type of join is called an Oracle RIGHT OUTER JOIN. This type of join
returns all rows from the RIGHT-hand table specified in the ON condition
and only those rows from the other table where the joined fields are equal (join
condition is met).
• Syntax
SELECT columns FROM table1 RIGHT [OUTER] JOIN table2 ON
table1.column = table2.column;
• In some databases, the RIGHT OUTER JOIN keywords are replaced with
RIGHT JOIN.
• The Oracle RIGHT OUTER JOIN would return the all records from table2 and
only those records from table1 that intersect with table2.
Swapnali Pawar GCEKarad
16
FULL OUTER JOIN
• Another type of join is called an Oracle FULL OUTER
JOIN. This type of join returns all rows from the LEFT-
hand table and RIGHT-hand table with nulls in place
where the join condition is not met.
• Syntax
SELECT columns FROM table1 FULL [OUTER] JOIN table2 ON
table1.column = table2.column;
• In some databases, the FULL OUTER JOIN keywords are replaced
with FULL JOIN.
• The Oracle FULL OUTER JOIN would return the all records from
both table1 and table2.
Swapnali Pawar GCEKarad
17
Swapnali Pawar GCEKarad
ROLL_NO NAME ADDRESS
1 Swapnali karad
2 Rugveda Pune
3 Sarika Mumbai
4 Chaitrali kolhapur
5 Pratima karad
6 Rupali pune
COURSE
_ID
COURSE_NAME ROLL_NO
101 CSE 1
101 CSE 2
102 MCA 3
103 BCA 4
105 IT 5
106 ENTC 6
StudentTable CourseTable
Primary Key
Foreign Key
Join Operation requires at least 1 Common Attribute
18
Swapnali Pawar GCEKarad
1. Primary Key-
Create table student(Roll_no int primary key,
name varchar(20),
Address varchar(20));
2. Foreign Key-
Create table Course(course_id varchar(10),
course_name varchar(30)
Roll_no int references student(Roll_no));
3. Insert into student values(1,'Swapnali','karad');
4. Insert into Course values(101,'CSE',1);
1.CreateTables with primary key & Foreign Key
& insert Records in that
19
Swapnali Pawar GCEKarad
EQUI-JOIN-
Select student.roll_no,Name,Course_name from
student , course where
student.roll_no=course.roll_no;
select student.roll_no,Name,Course_name
from student JOIN course On
student.roll_no=course.roll_no;
20
Swapnali Pawar GCEKarad
NON-EQUI JOIN-
Select student.roll_no,Name,Course_name from student,course
where student.roll_no!=course.roll_no;
21
Swapnali Pawar GCEKarad
SELF JOIN
Select s1.roll_no,S1.name,S2.Address from Student S1,student
S2 where S1.Address=S2.Address and S1.Roll_no!=S2.roll_no;
22
Swapnali Pawar GCEKarad
INNER JOIN
select student.roll_no,name,course_id,course_name from
student Inner Join Course on
student.roll_no=course.roll_no;
23
Swapnali Pawar GCEKarad
LEFT OUTER JOIN
Select student.roll_no,name,course_id,course_name from
student Left Outer Join Course on student.roll_no=course.roll_no;
24
Swapnali Pawar GCEKarad
RIGHT OUTER JOIN-
Select student.roll_no,name,course_id,course_name from student
RIGHT OUTER JOIN Course on student.roll_no=course.roll_no;
25
Swapnali Pawar GCEKarad
FULL OUTER JOIN-
Select student.roll_no,name,course_id,course_name from student
FULL OUTER JOIN Course on student.roll_no=course.roll_no;
26
Swapnali Pawar GCEKarad
Student Activity
1.CreateTable Employee & Department using Primary key &
Foreign key Respectively.
ENO E_Name Address DeptNo Location ENO
Employee Department
2. Perform Equi Join,Non-Equi Join ,Self Join,Inner Join,Left Outer
Join,Right Outer Join,Full Outer Join on Employee & Deparment
Table.
3. Find Employee Name who worked in department having
Location same as Address
27
Swapnali Pawar GCEKarad
28

More Related Content

What's hot (20)

PPTX
SQL JOIN
Ritwik Das
 
PPT
Constraints In Sql
Anurag
 
PPTX
SQL - DML and DDL Commands
Shrija Madhu
 
PPTX
SQL(DDL & DML)
Sharad Dubey
 
DOCX
Index in sql server
Durgaprasad Yadav
 
PPTX
SQL Joins.pptx
Ankit Rai
 
PPTX
DDL And DML
pnp @in
 
PPTX
Joins And Its Types
Wings Interactive
 
PPT
Sql joins
Berkeley
 
PDF
SQL Overview
Stewart Rogers
 
PDF
View & index in SQL
Swapnali Pawar
 
PPT
Sql join
Vikas Gupta
 
PPTX
sql function(ppt)
Ankit Dubey
 
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PPTX
Introduction to database & sql
zahid6
 
PPTX
Sql subquery
Raveena Thakur
 
PPTX
SQL Commands
Sachidananda M H
 
PPTX
Aggregate functions in SQL.pptx
SherinRappai
 
SQL JOIN
Ritwik Das
 
Constraints In Sql
Anurag
 
SQL - DML and DDL Commands
Shrija Madhu
 
SQL(DDL & DML)
Sharad Dubey
 
Index in sql server
Durgaprasad Yadav
 
SQL Joins.pptx
Ankit Rai
 
DDL And DML
pnp @in
 
Joins And Its Types
Wings Interactive
 
Sql joins
Berkeley
 
SQL Overview
Stewart Rogers
 
View & index in SQL
Swapnali Pawar
 
Sql join
Vikas Gupta
 
sql function(ppt)
Ankit Dubey
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Introduction to database & sql
zahid6
 
Sql subquery
Raveena Thakur
 
SQL Commands
Sachidananda M H
 
Aggregate functions in SQL.pptx
SherinRappai
 

Similar to SQL JOINS (20)

PPT
Sql Tutorials
Priyabrat Kar
 
PPTX
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
kailasmanoj
 
PPTX
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
kailasmanoj
 
PPTX
Joins in SQL
Pooja Dixit
 
PPTX
Oracle: Joins
DataminingTools Inc
 
PPTX
Oracle: Joins
oracle content
 
PPTX
1. dml select statement reterive data
Amrit Kaur
 
PPTX
SQL Fundamentals
Brian Foote
 
DOCX
Query
Raj Devaraj
 
PPTX
askndmf,dskmlf,bvdmk,v nmdsvjkmc,dvjkcmsdcvjnkmd
talhahakeem295
 
PPTX
Interactive SQL and Advance SQL SQL Performance Tuning.pptx
ssuserb8d5cb
 
PPT
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Uma Kakarlapudi
 
PDF
Lesson 6 - Relational Algebra.pdf
HasankaWijesinghe1
 
PPSX
Join query
Waqar Ali
 
PDF
Database Management System 1
Swapnali Pawar
 
PPTX
2..basic queries.pptx
MalaikaRahatQurashi
 
PPTX
Joins and Views.pptx
SangitaKabi
 
PPTX
Aggregate functions in SQL.pptx
SherinRappai1
 
PPTX
Rapid postgresql learning, part 3
Ali MasudianPour
 
PPTX
types of SQL Joins
vikram rajpurohit
 
Sql Tutorials
Priyabrat Kar
 
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
kailasmanoj
 
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
kailasmanoj
 
Joins in SQL
Pooja Dixit
 
Oracle: Joins
DataminingTools Inc
 
Oracle: Joins
oracle content
 
1. dml select statement reterive data
Amrit Kaur
 
SQL Fundamentals
Brian Foote
 
askndmf,dskmlf,bvdmk,v nmdsvjkmc,dvjkcmsdcvjnkmd
talhahakeem295
 
Interactive SQL and Advance SQL SQL Performance Tuning.pptx
ssuserb8d5cb
 
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Uma Kakarlapudi
 
Lesson 6 - Relational Algebra.pdf
HasankaWijesinghe1
 
Join query
Waqar Ali
 
Database Management System 1
Swapnali Pawar
 
2..basic queries.pptx
MalaikaRahatQurashi
 
Joins and Views.pptx
SangitaKabi
 
Aggregate functions in SQL.pptx
SherinRappai1
 
Rapid postgresql learning, part 3
Ali MasudianPour
 
types of SQL Joins
vikram rajpurohit
 
Ad

More from Swapnali Pawar (18)

PDF
Unit 3 introduction to android
Swapnali Pawar
 
PDF
Unit 1-Introduction to Mobile Computing
Swapnali Pawar
 
PDF
Unit 2.design mobile computing architecture
Swapnali Pawar
 
PDF
Introduction to ios
Swapnali Pawar
 
PDF
Fresher interview tips demo
Swapnali Pawar
 
PDF
Introduction to android
Swapnali Pawar
 
PDF
Android Introduction
Swapnali Pawar
 
PDF
Unit 2.design computing architecture 2.1
Swapnali Pawar
 
PDF
Unit 2 Design mobile computing architecture MC1514
Swapnali Pawar
 
PDF
Design computing architecture ~ Mobile Technologies
Swapnali Pawar
 
PDF
Exception Handling
Swapnali Pawar
 
PDF
Mobile technology-Unit 1
Swapnali Pawar
 
PDF
Mobile Technology 3
Swapnali Pawar
 
PDF
Web Programming& Scripting Lab
Swapnali Pawar
 
PDF
Mobile Technology
Swapnali Pawar
 
PDF
Mobile Technology
Swapnali Pawar
 
PDF
web programming & scripting 2
Swapnali Pawar
 
PDF
web programming & scripting
Swapnali Pawar
 
Unit 3 introduction to android
Swapnali Pawar
 
Unit 1-Introduction to Mobile Computing
Swapnali Pawar
 
Unit 2.design mobile computing architecture
Swapnali Pawar
 
Introduction to ios
Swapnali Pawar
 
Fresher interview tips demo
Swapnali Pawar
 
Introduction to android
Swapnali Pawar
 
Android Introduction
Swapnali Pawar
 
Unit 2.design computing architecture 2.1
Swapnali Pawar
 
Unit 2 Design mobile computing architecture MC1514
Swapnali Pawar
 
Design computing architecture ~ Mobile Technologies
Swapnali Pawar
 
Exception Handling
Swapnali Pawar
 
Mobile technology-Unit 1
Swapnali Pawar
 
Mobile Technology 3
Swapnali Pawar
 
Web Programming& Scripting Lab
Swapnali Pawar
 
Mobile Technology
Swapnali Pawar
 
Mobile Technology
Swapnali Pawar
 
web programming & scripting 2
Swapnali Pawar
 
web programming & scripting
Swapnali Pawar
 
Ad

Recently uploaded (20)

PDF
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
PDF
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Basics and rules of probability with real-life uses
ravatkaran694
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 

SQL JOINS

  • 1. Swapnali Pawar GCEKarad Database Lab Swapnali Pawar JOINS in SQL 1
  • 2.  Oracle JOINS are used to retrieve data from multiple tables.  JOIN clause combines rows from two or more tables.  creates a set of rows in a temporary table Joins Swapnali Pawar GCEKarad 2
  • 3. Types of SQL JOIN ❖ EQUI JOIN ● EQUI JOIN is a simple SQL join. ● Uses the equal sign(=) as the comparison operator for the condition ● NON EQUI JOIN uses comparison operator other than the equal sign. ● The operators uses like >, <, >=, <= with the condition. ❖ NON EQUI JOIN Swapnali Pawar GCEKarad 3
  • 4. Types of SQL EQUI JOIN ❖ INNER JOIN ❖ OUTER JOIN ● Returns only matched rows from the participating tables. ● Match happened only at the key record of participating tables. ● Returns all rows from one table and ● Matching rows from the secondary table and ● Comparison columns should be equal in both the tables. Swapnali Pawar GCEKarad 4
  • 5. List of SQL JOINS • INNER JOIN • LEFT JOIN OR LEFT OUTER JOIN • RIGHT JOIN OR RIGHT OUTER JOIN • FULL OUTER JOIN • NATURAL JOIN • CROSS JOIN • SELF JOIN Swapnali Pawar GCEKarad 5
  • 6. • SQL EQUI JOIN performs a JOIN against equality or matching columns values of the associated tables. An equal sign (=) is used as comparison operator in the where clause to refer equality. • You may also perform EQUI JOIN by using JOIN keyword followed by ON keyword and then specifying names of the columns along with their associated tables to check equality • Syntax : SELECT column_list FROM table1, table2.... WHERE table1.column_name = table2.column_name; • Example – SELECT student.name, student.id, record.class, record.city FROM student, record WHERE student.city = record.city; 1. EQUI JOIN Swapnali Pawar GCEKarad 6
  • 7. 1. EQUI JOIN 2nd way Syntax : SELECT column_list FROM table1 JOIN table2 ON (join_condition) Example – SELECT student.name, student.id, record.class, record.city FROM student JOIN record ON student.city = record.city; Swapnali Pawar GCEKarad 7
  • 9. Select * from Record; Select * from Student; SELECT student.name, student.id, record.class, record.city FROM Student JOIN Record ON Student.city = Record.city; Equi Join Example Swapnali Pawar GCEKarad 9
  • 10. NON-EQUI JOIN • Non-equi joins are joins whose join conditions use conditional operators other than equals • The SQL NON EQUI JOIN uses comparison operator instead of the equal sign like >, <, >=, <= along with conditions. • Syntax: SELECT * FROM table_name1, table_name2 WHERE table_name1.column [> | < | >= | <= ] table_name2.column Swapnali Pawar GCEKarad 10
  • 12. • A self join is a join in which a table is joined with itself (Unary relationships), specially when the table has a FOREIGN KEY which references its own PRIMARY KEY. • To join a table itself means that each row of the table is combined with itself and with every other row of the table. • The self join can be viewed as a join of two copies of the same table. self join Swapnali Pawar GCEKarad 12
  • 13. table_A SELECT * FROM table_A X, table_A Y WHERE X.A=Y.A; Output table_A Swapnali Pawar GCEKarad 13
  • 14. INNER JOIN (simple join) • It is the most common type of join. Oracle INNER JOINS return all rows from multiple tables where the join condition is met. • Syntax SELECT columns FROM table1 INNER JOIN table2 ON table1.column = table2.column; Swapnali Pawar GCEKarad 14
  • 15. LEFT OUTER JOIN • Another type of join is called an Oracle LEFT OUTER JOIN. This type of join returns all rows from the LEFT-hand table specified in the ON condition and only those rows from the other table where the joined fields are equal (join condition is met). • Syntax SELECT columns FROM table1 LEFT [OUTER] JOIN table2 ON table1.column = table2.column; • In some databases, the LEFT OUTER JOIN keywords are replaced with LEFT JOIN. • The Oracle LEFT OUTER JOIN would return the all records from table1 and only those records from table2 that intersect with table1. Swapnali Pawar GCEKarad 15
  • 16. RIGHT OUTER JOIN • Another type of join is called an Oracle RIGHT OUTER JOIN. This type of join returns all rows from the RIGHT-hand table specified in the ON condition and only those rows from the other table where the joined fields are equal (join condition is met). • Syntax SELECT columns FROM table1 RIGHT [OUTER] JOIN table2 ON table1.column = table2.column; • In some databases, the RIGHT OUTER JOIN keywords are replaced with RIGHT JOIN. • The Oracle RIGHT OUTER JOIN would return the all records from table2 and only those records from table1 that intersect with table2. Swapnali Pawar GCEKarad 16
  • 17. FULL OUTER JOIN • Another type of join is called an Oracle FULL OUTER JOIN. This type of join returns all rows from the LEFT- hand table and RIGHT-hand table with nulls in place where the join condition is not met. • Syntax SELECT columns FROM table1 FULL [OUTER] JOIN table2 ON table1.column = table2.column; • In some databases, the FULL OUTER JOIN keywords are replaced with FULL JOIN. • The Oracle FULL OUTER JOIN would return the all records from both table1 and table2. Swapnali Pawar GCEKarad 17
  • 18. Swapnali Pawar GCEKarad ROLL_NO NAME ADDRESS 1 Swapnali karad 2 Rugveda Pune 3 Sarika Mumbai 4 Chaitrali kolhapur 5 Pratima karad 6 Rupali pune COURSE _ID COURSE_NAME ROLL_NO 101 CSE 1 101 CSE 2 102 MCA 3 103 BCA 4 105 IT 5 106 ENTC 6 StudentTable CourseTable Primary Key Foreign Key Join Operation requires at least 1 Common Attribute 18
  • 19. Swapnali Pawar GCEKarad 1. Primary Key- Create table student(Roll_no int primary key, name varchar(20), Address varchar(20)); 2. Foreign Key- Create table Course(course_id varchar(10), course_name varchar(30) Roll_no int references student(Roll_no)); 3. Insert into student values(1,'Swapnali','karad'); 4. Insert into Course values(101,'CSE',1); 1.CreateTables with primary key & Foreign Key & insert Records in that 19
  • 20. Swapnali Pawar GCEKarad EQUI-JOIN- Select student.roll_no,Name,Course_name from student , course where student.roll_no=course.roll_no; select student.roll_no,Name,Course_name from student JOIN course On student.roll_no=course.roll_no; 20
  • 21. Swapnali Pawar GCEKarad NON-EQUI JOIN- Select student.roll_no,Name,Course_name from student,course where student.roll_no!=course.roll_no; 21
  • 22. Swapnali Pawar GCEKarad SELF JOIN Select s1.roll_no,S1.name,S2.Address from Student S1,student S2 where S1.Address=S2.Address and S1.Roll_no!=S2.roll_no; 22
  • 23. Swapnali Pawar GCEKarad INNER JOIN select student.roll_no,name,course_id,course_name from student Inner Join Course on student.roll_no=course.roll_no; 23
  • 24. Swapnali Pawar GCEKarad LEFT OUTER JOIN Select student.roll_no,name,course_id,course_name from student Left Outer Join Course on student.roll_no=course.roll_no; 24
  • 25. Swapnali Pawar GCEKarad RIGHT OUTER JOIN- Select student.roll_no,name,course_id,course_name from student RIGHT OUTER JOIN Course on student.roll_no=course.roll_no; 25
  • 26. Swapnali Pawar GCEKarad FULL OUTER JOIN- Select student.roll_no,name,course_id,course_name from student FULL OUTER JOIN Course on student.roll_no=course.roll_no; 26
  • 27. Swapnali Pawar GCEKarad Student Activity 1.CreateTable Employee & Department using Primary key & Foreign key Respectively. ENO E_Name Address DeptNo Location ENO Employee Department 2. Perform Equi Join,Non-Equi Join ,Self Join,Inner Join,Left Outer Join,Right Outer Join,Full Outer Join on Employee & Deparment Table. 3. Find Employee Name who worked in department having Location same as Address 27