2. A
join is actually performed by the where clause which combines the specified
rows of tables.
3. If a join involves in more than two tables then Oracle joins first two
tables based on the joins condition and then compares the result with the next
table and so on.
TYPES
1 Equi join
2 Non-equi join
3 Self join
4 Natural join
5 Cross join
6 Outer join
- Left outer
- Right outer
- Full outer
7 Inner join
8 Using clause
9 On clause
9 On clause
Assume that we have the following tables.
SQL> select * from dept;
DEPTNO
|
DNAME
|
LOC
|
10
|
INVENTORY
|
HYBD
|
20
|
FINANCE
|
BGLR
|
30
|
HR
|
MUMBAI
|
SQL> select * from emp;
EMPNO
|
ENAME
|
JOB
|
MGR
|
DEPTNO
|
111
|
saketh
|
analyst
|
444
|
10
|
222
|
sudha
|
clerk
|
333
|
20
|
333
|
jagan
|
manager
|
111
|
10
|
444
|
madhu
|
engineer
|
222
|
40
|
1.
EQUI JOIN
A join which contains an equal to ‘=’ operator in the joins condition.
Ex:
SQL> select
empno,ename,job,dname,loc from emp e,dept d where e.deptno=d.deptno;
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
Using clause
SQL> select empno,ename,job ,dname,loc from
emp e join dept d using(deptno);
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
On clause
SQL> select empno,ename,job,dname,loc from emp
e join dept d on(e.deptno=d.deptno);
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
2. NON-EQUI JOIN
A join which contains an operator other than equal to ‘=’ in the joins
condition.
Ex:
SQL> select empno,ename,job,dname,loc from emp
e,dept d where e.deptno > d.deptno;
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
222
|
sudha
|
clerk
|
INVENTORY
|
HYBD
|
444
|
madhu
|
engineer
|
INVENTORY
|
HYBD
|
444
|
madhu
|
engineer
|
FINANCE
|
BGLR
|
444
|
madhu
|
engineer
|
HR
|
MUMBAI
|
3. SELF JOIN
Joining the table itself is called self join.
Ex:
SQL> select
e1.empno,e2.ename,e1.job,e2.deptno from emp e1,emp e2 where e1.empno=e2.mgr;
EMPNO
|
ENAME
|
JOB
|
DEPTNO
|
111
|
jagan
|
analyst
|
10
|
222
|
madhu
|
clerk
|
40
|
333
|
sudha
|
manager
|
20
|
444
|
saketh
|
engineer
|
10
|
4. NATURAL JOIN
Natural join compares all the common columns.
Ex:
SQL> select empno,ename,job,dname,loc from emp
natural join dept;
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
5. CROSS JOIN
This will gives the cross product.
Ex:
SQL> select empno,ename,job,dname,loc from emp
cross join dept;
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
444
|
madhu
|
engineer
|
INVENTORY
|
HYBD
|
111
|
saketh
|
analyst
|
FINANCE
|
BGLR
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
333
|
jagan
|
manager
|
FINANCE
|
BGLR
|
444
|
madhu
|
engineer
|
FINANCE
|
BGLR
|
111
|
saketh
|
analyst
|
HR
|
MUMBAI
|
222
|
sudha
|
clerk
|
HR
|
MUMBAI
|
333
|
jagan
|
manager
|
HR
|
MUMBAI
|
444
|
madhu
|
engineer
|
HR
|
MUMBAI
|
6. OUTER JOIN
Outer join gives the non-matching records along with matching records.
LEFT OUTER
JOIN
This will display the all matching records and the records which are in
left hand side table those that are not in right hand side table.
Ex:
SQL> select empno,ename,job,dname,loc from emp
e left outer join dept d
on(e.deptno=d.deptno);
Or
SQL> select empno,ename,job,dname,loc from emp
e,dept d where
e.deptno=d.deptno(+);
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
444
|
madhu
|
engineer
|
RIGHT OUTER JOIN
This will display the all matching records and the records which are in
right hand side table those that are not in left hand side table.
Ex:
SQL> select empno,ename,job,dname,loc from emp
e right outer join dept d
on(e.deptno=d.deptno);
Or
SQL> select empno,ename,job,dname,loc from emp e,dept d
where e.deptno(+) =
d.deptno;
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
HR
|
MUMBAI
|
FULL OUTER JOIN
This will display the all matching records and the non-matching records
from both tables.
Ex:
SQL> select empno,ename,job,dname,loc from emp
e full outer join dept d
on(e.deptno=d.deptno);
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerk
|
FINANCE
|
BGLR
|
444
|
madhu
|
engineer
|
||
HR
|
MUMBAI
|
7. INNER JOIN
This will display all the records that have matched.
Ex:
SQL> select empno,ename,job,dname,loc from emp
inner join dept using(deptno);
EMPNO
|
ENAME
|
JOB
|
DNAME
|
LOC
|
111
|
saketh
|
analyst
|
INVENTORY
|
HYBD
|
333
|
jagan
|
manager
|
INVENTORY
|
HYBD
|
222
|
sudha
|
clerkx`
|
FINANCE
|
BGLR
|
If you like this post, please share it on google by clicking on the
Google +1 button.
Please go through similar Oracle Posts @DWHLAUREATE:
WHAT ARE EXTERNAL TABLES IN ORACLE
SUPERB JOB.!!
ReplyDeleteThanks harish for your comments
Deleterealy explained well...specially examples
DeleteGood one. Thanks for the tutorial. Keep these comming.
ReplyDeleteSure Zubair
DeleteExcellent
DeleteAmazing tutorial
ReplyDeleteSimple and easy to understand.. Thanks!!
ReplyDeleteExcellent post and the blogs also dear..
ReplyDeleteThanks.. :)
Thanks for the comments Ajit :)
DeleteExplained in a simple and elegant manner !!! Kudos for the good work :)
ReplyDeletereally helpfull,Thanks
ReplyDeletereally useful to me
ReplyDeleteNICE AN INFORMATIVE FOR LEARNING KEEP UP
ReplyDeleteThankyou Everyone..Keep supporting so that we can put more informative posts like this.....
ReplyDeleteTHANKS THIS WAS HELPFUL
ReplyDeleteEASY STEPS TO UNDERSTAND FOR A BEGINNER,REALLY EXCELLENT JOB
ReplyDeletevery easy steps for understanding of join in oracle
ReplyDeletehelpful...........
ReplyDeletevery very nice for BEGINNER
ReplyDeletegood one
ReplyDeleteGood material
ReplyDeletenice informstion for learning..........superb
ReplyDeletethanks a lot!
ReplyDeleteCan we retrieve multiple row data without join? using only where clause
ReplyDeleteU can retrieve multiple row data without join, but u cant rerieve multiple table row data.
DeleteNice, short and to the point explanation.....keep it up
ReplyDeleteThere two tables employee & department for some employee department is not assigned. Write the outer join that will return all employees that have departments associated with them & those for which no department is there.
ReplyDeleteI hope u dont hv any confusion dear....follow the above mentioned example
DeleteDifference between equi join and the inner join ???
ReplyDeleteThere is no difference between these two above mentioned in practicality, but by the fact is equi join belongs to Oracle Proprietary joins (8i and prior) whereas inner join is belongs to ANSI SQL: 1999 Compliant joins
DeleteInner join can have equality (=) and other operators (like <,>,<>) in the join condition.
DeleteEqui join only have equality (=) operator in the join condition.
Explained in a good manner.. really useful thank you....
ReplyDeleteWonderful Job!!!! This blog is very helpful.
ReplyDeleteits very helpful to understand join
ReplyDeleteGood one,Really helpful
ReplyDeleteGood job
ReplyDeleteGood Example for easy understanding !! Keep it up ..
ReplyDeleteI found really good. Thank you
ReplyDeleteReally Useful ............... Thanks for it.
ReplyDeleteThank You all for the valuable comments....Please check out our latest post on Unix
ReplyDeletehttp://dwhlaureate.blogspot.in/2013/12/how-to-do-sorting-in-unix.html
good one...
ReplyDeleteExcellent Job - Venkad
ReplyDeleteThank you it's very use full for us
ReplyDeleteOnly one word, WOW
ReplyDeleteI have seen some where joins are explain using venn diagram,
If feasible then please...
Grate yar...Its simple to understand
ReplyDeleteUser friendly and easy to understand
ReplyDeleteI have some requirement like this
ReplyDeleteselect *
from emp
where ename like 'S%';
without using like operator i need to retrieve data
select ename from emp where substr(ename,1,1)='S';
DeleteYes it is good pattern matching statement.
DeleteSuperb
ReplyDeletewhat is the difference between equi join and natural join and inner join??????
ReplyDeleteindeed great job.. so clearly stated with examples.
ReplyDeleteReally good and understandable....Can you please explain how the cross join works once?
ReplyDeleteExcellent job..took just 5 mins to understand joins..
ReplyDeleteNice tutorial.. superb:)
ReplyDeleteGreat work bro........ :)
ReplyDeleteJust Awsome........
ReplyDeleteyour using clause example is wrong
ReplyDeleteits right yar..where you have dought
Deletegood explanation
ReplyDeleteGr8 job bro, thanks fr this help. :)
ReplyDeleteGreat job bro, thanks for this.
ReplyDeletei hope this helps to everybody
Quite helpful n easy to understand. Thanks a ton.....
ReplyDeletei am beginner but i underder stood easily nice document thank u sir
ReplyDeleteFantastic work, simple but brief ....... Thanks
ReplyDeletethanks buddy
ReplyDeleteThanks Dude
ReplyDeleteGood one buddy
ReplyDeleteThen what is the difference between equijoin and inner join?
ReplyDeleteExcellent guide! Thanks!!
ReplyDeleteexcellent.great job.explained in a simple manner.
ReplyDeleteThank you so much fr the wonderful explanation ..
ReplyDeleteKeep up the good work and keep posting ..
:)
thanks.......
ReplyDeleteSuper Great Job..!!
ReplyDeletebahut badhiya yaar. thanks
ReplyDeleteSimply superb
ReplyDelete@Viki J
ReplyDeleteYou can use Regexp_Like() function
Superb explanation... Short and Concise.. up to the mark.. Thanks for sharing... keep on.
ReplyDeleteExcellent
ReplyDeleteHey!!! I havn't seen such a dedicated/clear explanation anywhere till now..Thanks a loot!!!
ReplyDeleteExcellent
ReplyDeleteGreat job.Keep it up
ReplyDeleteNeat Explanation... Thanks for sharing...
ReplyDeleteGood work..its really helpful and easy to understand to everyone.thanx
ReplyDeletereally helpful.
ReplyDeleteThanks
ReplyDeletethanks a lot....
ReplyDeleteGood examples with good explanation...
ReplyDeletereally help.. thanks.
ReplyDeleteI would very grateful if any one explain REGEXP_LIKE in a very extent.
ReplyDeleteThank you..
thanks...
ReplyDeletethanks its easy
ReplyDeletethanks its easy
ReplyDeletethanks
ReplyDeletenice...i have easily understand
ReplyDeletethanks '
ReplyDeletevery simple method
ReplyDeleteself join is not getting exicute
ReplyDeleteerror name
ERROR at line 1:
ORA-00904: "E2"."EMPNO": invalid identifier
Why any one use cross join ? Data output does not make sense.
ReplyDeleteGood one...explained in two ways.Thank alot
ReplyDeleteEasy to learn types of joins...excellent work
ReplyDeletei through out all of my confuse about Joining by this work
ReplyDeletethanks a lot.
This article has examples which helped me lot , thanks .
ReplyDeleteThanks dear. Its very Good . I have a confusion about join now clear everything.
ReplyDeletegood and helpfull
ReplyDeleteVery interesting analysis. Great information. Since last week, I am gathering details about Oracle. There are some amazing details on your blog which I didn't know. Thanks.
ReplyDeletehello every one please send realtime example on join conditions
ReplyDeleteLoving the info on this internet site, you have done outstanding job on the content. I followed each and every step. and it is successful.
ReplyDeleteSuch a very useful article. Very interesting to read this.I would like to thank you for the efforts you had made for writing this awesome article.
I’ve been following you since you’ve started your blog.This is top notch information and I'm really happy to connect with your great work.
ReplyDeleteSuperb information from this article and I have to tell you, your blog giving the best and useful information.
Thank you for awesome blog.it helped me a lot :)
Hiya, I’m really glad I have found this information. ��
ReplyDeleteToday bloggers publish only about gossips and net and this is really annoying. A good web site with interesting content, this is what I need. Thanks for keeping this web site, I’ll be visiting it.
Thanks for for sharing ur knowledge.
ReplyDeleteRELLY GOOD
ReplyDeleteReally good
ReplyDeleteReally awesome blog, Informative and knowledgeable content. Keep sharing more with us.
ReplyDeleteMMORPG OYUNLAR
ReplyDeleteinstagram takipçi satın al
Tiktok Jeton Hilesi
tiktok jeton hilesi
SAC EKİMİ ANTALYA
ınstagram takipçi satin al
İnstagram Takipçi Satın Al
metin2 pvp serverler
instagram takipci satın al
FON PERDE MODELLERİ
ReplyDeleteMOBİL ONAY
Mobil odeme bozdurma
nft nasıl alinir
ankara evden eve nakliyat
trafik sigortası
dedektör
web sitesi kurma
aşk kitapları
Smm panel
ReplyDeletesmm panel
Https://isilanlariblog.com
instagram takipçi satın al
Hırdavatçı
WWW.BEYAZESYATEKNİKSERVİSİ.COM.TR
Servis
TİKTOK JETON HİLE
Good content. You write beautiful things.
ReplyDeletevbet
mrbahis
hacklink
vbet
sportsbet
taksi
hacklink
mrbahis
korsan taksi
Good article text write content successfull... thanks.
ReplyDeleteslot siteleri
kibris bahis siteleri
tipobet
bonus veren siteler
poker siteleri
betmatik
betpark
kralbet
başakşehir
ReplyDeletebayrampaşa
beşiktaş
beykoz
beylikdüzü
ZNW
mecidiyeköy
ReplyDeletesakarya
istanbul
kayseri
ordu
YDY
hatay
ReplyDeleteığdır
ısparta
mersin
ağrı
ZA30N1
https://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
8MDR2
xxlargeseo
ReplyDeletexxlargeseodigi
digi.seo
RMX
ytjytkjytkuyikluyyul
ReplyDeleteشركة تنظيف
شركة تنظيف شقق بالقطيف rZEdja1y5i
ReplyDeleteصيانة افران بمكه HFwA7dKT9t
ReplyDeleteافران جدة bvFSsAXIba
ReplyDeleteشركة عزل اسطح بالجبيل 4MSplu7twn
ReplyDeleteشركة تسليك مجاري بالجبيل m5Qd4Stq4I
ReplyDelete