Application Development 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: 

Inner and outer Joins

Former Member
0 Kudos

Hi

I have three tables that i want link. I want to return values from table ISEG even if data does not exist in MSEG and MKPF.

Currently no data are returned when data in mkpf does not exists. I've joined mseg and mkpf with a inner join.


  SELECT a~matnr a~werks  SUM( a~menge ) SUM( a~buchm ) SUM( b~menge )                                                                                
INTO  TABLE wa_outtab
      FROM iseg AS a
      LEFT OUTER JOIN mseg AS b
          ON    b~matnr = a~matnr
      INNER JOIN  mkpf AS c
          ON    c~mblnr =   b~mblnr      AND 
                   c~mjahr =   b~mjahr      AND
                                                                                c~bldat >=  idate-low     AND
                   c~bldat <=  idate-high
       WHERE
        a~iblnr IN iblnr 
           GROUP BY   a~matnr a~werks .

1 ACCEPTED SOLUTION

srinivas_akiri
Active Participant
0 Kudos

Hi

Your statement will do an LEFT OUTER JOIN between iseg and mseg then it will do the INNER JOIN between the above result set and mkpf table.

that is why you are not able to get values when there is no data exists in mkpf.

try to rearrange the tables as below:

mseg INNER JOIN mkpf RIGHT OUTER JOIN iseg.

or split the join.

Thanks

Srini

1 REPLY 1

srinivas_akiri
Active Participant
0 Kudos

Hi

Your statement will do an LEFT OUTER JOIN between iseg and mseg then it will do the INNER JOIN between the above result set and mkpf table.

that is why you are not able to get values when there is no data exists in mkpf.

try to rearrange the tables as below:

mseg INNER JOIN mkpf RIGHT OUTER JOIN iseg.

or split the join.

Thanks

Srini