Вы находитесь на странице: 1из 10

JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.

html
1 of 10 7/7/2014 2:56 PM
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
2 of 10 7/7/2014 2:56 PM
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
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
3 of 10 7/7/2014 2:56 PM
at 16:40
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 liked the above post Please go through below
useful links too,
What is Index and Its Use?
How to do Top-N analysis in Oracle
Correlated Sub Queries
What is an Inline View?
65 comments:
Harish Pandalangatt 9 June 2013 11:55
SUPERB JOB.!!
Reply
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
4 of 10 7/7/2014 2:56 PM
Replies
Reply
Replies
Reply
Replies
Reply
DWHLAUREATE 18 June 2013 00:28
Thanks harish for your comments
Zubair Aslam 15 June 2013 19:19
Good one. Thanks for the tutorial. Keep these comming.
Reply
DWHLAUREATE 18 June 2013 00:29
Sure Zubair
venkatesulu bestha 21 June 2013 10:34
Excellent
Reply
Anonymous 24 June 2013 15:02
Amazing tutorial
Reply
Anonymous 26 June 2013 01:56
Simple and easy to understand.. Thanks!!
Reply
Ajit kumar 28 June 2013 15:15
Excellent post and the blogs also dear..
Thanks.. :)
Reply
DWHLAUREATE 10 August 2013 01:11
Thanks for the comments Ajit :)
Vamsi Krishna Nasanam 16 July 2013 18:54
Explained in a simple and elegant manner !!! Kudos for the good work
:)
Reply
Navnath Mane 23 July 2013 12:07
really helpfull,Thanks
Reply
aksh 27 July 2013 15:53
really useful to me
Reply
10 Formation 2 August 2013 23:55
NICE AN INFORMATIVE FOR LEARNING KEEP UP
Reply
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
5 of 10 7/7/2014 2:56 PM
Replies
Reply
DWHLAUREATE 10 August 2013 01:13
Thankyou Everyone..Keep supporting so that we can put more
informative posts like this.....
Reply
tushar kadam 11 August 2013 13:26
THANKS THIS WAS HELPFUL
Reply
Irfan 11 August 2013 17:32
EASY STEPS TO UNDERSTAND FOR A BEGINNER,REALLY
EXCELLENT JOB
Reply
ashwani kumar 27 August 2013 17:51
very easy steps for understanding of join in oracle
Reply
Anonymous 28 August 2013 14:56
helpful...........
Reply
Anonymous 8 September 2013 11:51
Reply
Mukesh Pandey 10 September 2013 15:11
good one
Reply
govind 10 September 2013 22:44
Good material
Reply
kuchipudi harikrishna 11 September 2013 12:44
nice informstion for learning..........superb
Reply
Kangabam 23 September 2013 21:02
thanks a lot!
Reply
Deepti m 1 October 2013 10:14
Can we retrieve multiple row data without join? using only where clause
Reply
Md Atif 11 November 2013 08:38
U can retrieve multiple row data without join, but u cant
rerieve multiple table row data.
Omesh Prasad Sinha 16 October 2013 14:49
Nice, short and to the point explanation.....keep it up
Reply
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
6 of 10 7/7/2014 2:56 PM
Replies
Reply
Replies
Reply
Ramchand Damacharla 26 October 2013 20:54
There 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.
Reply
Md Atif 11 November 2013 08:54
I hope u dont hv any confusion dear....follow the above
mentioned example
Raushan Sinha 29 October 2013 23:42
Difference between equi join and the inner join ???
Reply
Md Atif 11 November 2013 08:49
There 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
Veeru Golakoti 1 November 2013 18:57
Explained in a good manner.. really useful thank you....
Reply
VAMSI 6 November 2013 11:50
Wonderful Job!!!! This blog is very helpful.
Reply
manijee 9 November 2013 12:15
its very helpful to understand join
Reply
vinu 9 November 2013 18:49
Good one,Really helpful
Reply
Md Atif 11 November 2013 08:27
Good job
Reply
Madhav 14 November 2013 18:20
Good Example for easy understanding !! Keep it up ..
Reply
Niroj Shrestha 17 November 2013 07:49
I found really good. Thank you
Reply
VIRAL PATVA 7 December 2013 12:39
Really Useful ............... Thanks for it.
Reply
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
7 of 10 7/7/2014 2:56 PM
DWHLAUREATE 8 December 2013 11:30
Thank You all for the valuable comments....Please check out our latest
post on Unix
http://dwhlaureate.blogspot.in/2013/12/how-to-do-sorting-
in-unix.html
Reply
Sanjay Mishra 30 December 2013 00:33
good one...
Reply
Anonymous 3 January 2014 19:00
Excellent Job - Venkad
Reply
Kavya Kalapala 5 January 2014 11:46
Thank you it's very use full for us
Reply
Vivek Seth 5 January 2014 17:28
Only one word, WOW
I have seen some where joins are explain using venn diagram,
If feasible then please...
Reply
Santosh Suryawanshi 14 January 2014 18:44
Grate yar...Its simple to understand
Reply
Jitesh Kadam 22 January 2014 10:15
User friendly and easy to understand
Reply
Viki j 31 January 2014 12:12
I have some requirement like this
select *
from emp
where ename like 'S%';
without using like operator i need to retrieve data
Reply
ritesh velaga 2 February 2014 19:56
Superb
Reply
Atchutu B 4 February 2014 14:35
what is the difference between equi join and natural join and inner
join??????
Reply
Anonymous 11 February 2014 09:47
indeed great job.. so clearly stated with examples.
Reply
Anonymous 19 February 2014 15:07
Really good and understandable....Can you please explain how the cross
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
8 of 10 7/7/2014 2:56 PM
join works once?
Reply
Anonymous 20 February 2014 13:21
Excellent job..took just 5 mins to understand joins..
Reply
Anonymous 22 February 2014 09:49
Nice tutorial.. superb:)
Reply
Anonymous 13 March 2014 00:39
Great work bro........ :)
Reply
Subho 1 April 2014 23:35
Just Awsome........
Reply
BHANUPRAKASH SG 14 April 2014 00:12
your using clause example is wrong
Reply
Ravi Neeluri 14 April 2014 23:26
Reply
shivaram vollala 18 April 2014 15:54
good explanation
Reply
pankaj dagar 24 April 2014 12:37
Gr8 job bro, thanks fr this help. :)
Reply
sanjib pradhan 6 May 2014 17:44
Great job bro, thanks for this.
i hope this helps to everybody
Reply
Anonymous 9 May 2014 03:01
Quite helpful n easy to understand. Thanks a ton.....
Reply
Sai Krishna 15 May 2014 11:59
i am beginner but i underder stood easily nice document thank u sir
Reply
vishwak raja 23 May 2014 12:20
Fantastic work, simple but brief ....... Thanks
Reply
Anonymous 28 May 2014 15:43
thanks buddy
Reply
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
9 of 10 7/7/2014 2:56 PM
Newer Post Older Post Home
Subscribe to: Post Comments (Atom)
Comment as:
Publish

Anonymous 4 June 2014 15:31
Thanks Dude
Reply
ashmantak 19 June 2014 09:28
Good one buddy
Reply
JOINS IN ORACLE-different joins in oracle with examples http://dwhlaureate.blogspot.in/2012/08/joins-in-oracle.html
10 of 10 7/7/2014 2:56 PM

Вам также может понравиться