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 and outer joints

Former Member
0 Likes
1,283

please tell me in detail about inner and outer joins.I am novice to this technology.

please tell me in detail about inner and outer joins.I am novice to this technology.

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
880

Inner joins allow you to retrieve data from 2 or more database tables simutaniously. You join them using the keys of the tables. THere must be a matching record in both(all) database tables referenced in the select.

Outt joins are just like inner joins, but you don't have to have a matching record in the outter joined table, if no match per the key, the data will still be retrieved for the table on the left.

http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/frameset.htm

Regards,

Rich Heilman

Read only

Former Member
0 Likes
880

Hi Bharat,

<b>Specifying Two or More Database Tables as an Inner Join</b>

In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:

SELECT...

...

FROM <tab> [INNER] JOIN <dbtab> [AS <alias>] ON <cond> <options>

...

where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.

A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.

The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.

The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.

<b>Specifying Two or More Database Tables as a Left Outer Join</b>

In an inner join, a line from the left-hand database table or join is only included in the selection if there is one or more lines in the right-hand database table that meet the ON condition <cond>. The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.

SELECT...

...

FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond>

<options>

...

<tab> and <dbtab> are subject to the same rules and conditions as in an inner join. The OUTER addition is optional. The tables are linked in the same way as the inner join with the one exception that all lines selected from <tab> are included in the final selection. If <dbtab> does not contain any lines that meet the condition <cond>, the system includes a single line in the selection whose columns from <dbtab> are filled with null values.

In the left outer join, more restrictions apply to the condition <cond> than in the inner join. In addition to the above restrictions:

EQ or = is the only permitted relational operator.

There must be at least one comparison between columns from <tab> and <dbtab>.

The WHERE clause may not contain any comparisons with columns from <dbtab>. All comparisons using columns from <dbtab> must appear in the condition <cond>.

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
880

Hi,

Inner joins are used when you need to extract related information from 2 tables based on common primary key.

Outer join shall fetch all the unmatched data as well..

Regards,

Tanveer.

<b>Please mark helpful answers</b>

Read only

Former Member
0 Likes
880

Hi bharat,

With the use of outer join you can join the tables even there is no entry in all the tables used in the view.

In case of inner join there should be an entry in al the tables use in the view.

check this link:

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm

reward if helpful.

regards,

keerthi.

Read only

Former Member
0 Likes
880

Hi Bharat

help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm

help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/content.htm

www.experts-exchange.com/Databases/Oracle/Q_20794022.html

database.ittoolbox.com/documents/popular-q-and-a/inner-and-outer-join-sql-statements

Regards,

Laxmi.