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

Outer join, use in a query.

Former Member
0 Likes
1,723

Hi forum!

I want to do a query among three tables keeping empties rows. Is this possible to do with an outer join?

Could anybody give me an example how to use it¿?

Thanks in advance and regards,

Mon

Hi forum!

I want to do a query among three tables keeping empties rows. Is this possible to do with an outer join?

Could anybody give me an example how to use it¿?

Thanks in advance and regards,

Mon

4 REPLIES 4
Read only

Former Member
0 Likes
918

When joining more than one table, you can use one outer join in the select statement, so if your missing rows are in one table, you can do the outer join on that table.

Rob

Read only

0 Likes
918

Hi again.

Is it possible to do a query outer join among three tables in the same query¿?

Any suggestion or example¿?

Mon

Read only

Former Member
0 Likes
918

Yes you can use outer join for the same.

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>. <b>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.</b>

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>.

For details and examples of outer join please have a look at below links.

http://help.sap.com/saphelp_nw04/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm

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

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers