Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

emp_id dept_name

1 Eng
2 Doctor
3 Teacher
4 Lawyer

select *from emp_id cross join dept_name;

Emp_id Dept_name
1 Eng
2 Eng
3 Eng
4 Eng
1 Doctor
2 Doctor
3 Doctor
4 Doctor
1 Teacher
2 Teacher
3 Teacher
4 Teacher
1 Lawyer
2 Lawyer
3 Lawyer
4 Lawyer

EQUI JOIN : the join in which columns are compared for equlity is
called EQUI-JOIN. In equi join, we use(*) in the select list so that
common column will appears twice in the output.

PARENT
Id Name City
1 A Pune
2 B Goa
3 C Delhi

CHILD

ID Child_name City
1 Chintu Delhi
2 Sonu Goa
3 Monu pune

select name from parent, child where parent.id=child.id and


parent.city=child.city;

output :

Name
B

select *from child, parent where child.id=parent.id;

output :

Id Name City Id Child_name City


1 A Pune 1 Chintu Delhi
2 B Goa 2 Sonu Goa
3 C Delhi 3 Monu pune
NATURAL JOIN : In natural join, only one of the identical column exists.
Is eliminates the duplicate column. In natural join , we specify the name
of column in place of (*) which is responsible for duplicate column.

In natural join, when both the table have some column name and
that column is being fetched in the query then the condition of
ambiguity arises that from which table that column is to be fetched.

STUDENT

Roll_no Name
1 Shri
2 Raju
3 Pooja

MARKS

Roll_no Marks
2 70
3 60
4 80

select name from student natural join marks;

output :

Name
Raju
Pooja

You might also like