Ch8_Joins and Set Operations
Ch8_Joins and Set Operations
Now we want to
fetch details of
employee along
with its
corresponding
matching
department. Like
for ‘alam’ deptno
is 10 so from dept
table it should
show deptno 10
details and so on
Equi-join
Common
Column
appears
twice in
output
From the above query, we can observe that while doing equi-join we have to give
equality condition on common column of both table so that it picks related
records
Equi-join
We can also give Table Alias i.e. nick name for table name and further we can use
this name any where in query in place of table name. This is helpful when table
name is of big length and we can shorten the query
Natural Join
• The JOIN in which only one of the identical
columns exists in called Natural Join. It is
similar to Equi-join except that duplicate
columns are eliminated in Natural join that
would otherwise appear in Equi-Join.
• In natural join we specify the names of column
to fetch in place of (*) which is responsible of
appearing common column twice in output.
See here, we are not giving
*, like
fetch
Natural Join
Natural Join
• Or
For empno 5 no
matching data in
second table so NULL
will be output
RIGHTJOIN
• When using RIGHT JOIN all rows from second
table i.e. right hand side table will be returned
whether there are matches in first table or not.
For the rows whose matching values are not
found in first table it will display NULL value.
Suppose we want to Select pid, pname and ename from both table, and we want
all the employee name record must come whether employee is working on a
project or not.