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

Table Joins

Former Member
0 Likes
687

There are 2 Internal Table

Table Row

A B C D

Table 1

A1 B1 C1 D1

A2 B2 C2 D2

A3 B3 C3 D3

Table 2

K1 K2 K3 D1

F1 F2 F3 D1

G1 G2 G3 D1

M1 M2 M3 D2

H1 H2 H3 D2

P1 P2 P3 D3

Output

I am comparing only row D between two tables the output should be as follows

A1 B1 C1 D1 K1 K2 K3 D1

A1 B1 C1 D1 F1 F2 F3 D1

A1 B1 C1 D1 G1 G2 G3 D1

A2 B2 C2 D2 M1 M2 M3 D2

A2 B2 C2 D2 H1 H2 H3 D2

A3 B3 C3 D3 P1 P2 P3 D3

How to write the table join query. Table1 should be the primary table.

Thanks

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
666

loop at table1 into wa_table1.
  lopp at table2 into wa_table2 where d = wa_table1-d.
    move-corresponding wa_table2 to wa_final.
    move-corresponding wa_table1 to wa_final.
append wa_final into itab_final.
endloop.
endloop.


select ....
          from table1 as a 
      join table2 as b
      on a~d = b~d.

4 REPLIES 4
Read only

former_member156446
Active Contributor
0 Likes
667

loop at table1 into wa_table1.
  lopp at table2 into wa_table2 where d = wa_table1-d.
    move-corresponding wa_table2 to wa_final.
    move-corresponding wa_table1 to wa_final.
append wa_final into itab_final.
endloop.
endloop.


select ....
          from table1 as a 
      join table2 as b
      on a~d = b~d.

Read only

0 Likes
666

Hi Jay Sadaram

It Works Great!!!

Thanks

Read only

sergio_cifuentes
Participant
0 Likes
666

SELECT * FROM TABLE 1 INNER JOIN TABLE 2 ON TABLE1-D = TABLE2-D

Read only

0 Likes
666

Sorry ! I will try your code

Thanks

Edited by: Senthilramkumar on Feb 6, 2008 7:49 PM