Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Inner join and left outer join

Former Member
0 Likes
1,264

Hello experts ,

I was create join between 7 tables in my query , how can i know when i must to use with inner join and when use with left outer join , and i want to know what is the different with inner join and left outer join generally ?

Thanks for your help ,

Avi.

4 REPLIES 4
Read only

Former Member
0 Likes
999

Inner join is used to get all enteries fronm 2nd table which has it's corresponding in 1st table, means on which field condition inner join is made.

but suppose in ist table there is a field which has a value but in inner join table that field has no corresponding value than the field of ist table will also not be shown while selecting.means value of the fields from both table will not be picked.

but when u use left outer join it will pick the values from ist table too however it have no corresponding value in 2nd table.

in short.

The INNER JOIN keyword return rows when there is at least one match in both tables.
The LEFT Outer JOIN keyword returns all rows from the left table (table_name1), even if there are 
no matches in the right table (table_name2).


hope u got it

Edited by: tahir naqqash on Feb 22, 2009 2:06 PM

Read only

Former Member
0 Likes
999

Hi,

Please [search|https://www.sdn.sap.com/irj/scn/advancedsearch?query=innerjoinandleftouter+join&cat=sdn_all] the SCN before the Posting. You can find the lot of thread's for your query.

Read only

Former Member
0 Likes
999
Read only

Former Member
0 Likes
999

hi,

inner join produces a result set of only those records from the left(outer) table for which there is a corresponding entry in the right(inner) table.

left outer join produces a result set of all records from the left(outer) table irrespective of whether there is a corresponding entry in the right(inner) table.

use inner join when u want to combine two tables based on common field values.Else use left outer join.

tab1

f1 f2 f3

a1 b1 c1

a2 b2 c2

a3 b3 c3

tab1

f1 f2 f4

a1 b1 d1

a2 b2 d2

a4 b4 d4

SELECT sf1 sf2 sf3 pf4 INTO TABLE itab

FROM tab1 AS s INNER JOIN tab2 AS p

ON sf1 = pf1 AND sf2 = pf2.

result:(for f1=a3 and f2=b3 there is no entry in tab2 .....so that row is not included in itab)

itab

f1 f2 f3 f4

a1 b1 c1 d1

a2 b2 c2 d2

SELECT sf1 sf2 sf3 pf4 INTO TABLE itab

FROM tab1 AS s LEFT OUTER JOIN tab2 AS p

ON sf1 = pf1 AND sf2 = pf2.

result:(for f1=a3 and f2=b3 row is included in itab)

itab

f1 f2 f3 f4

a1 b1 c1 d1

a2 b2 c2 d2

a3 b3 c3

Regards

Jay