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: 

join condition

Former Member
0 Kudos
90

Hi,

i have a requirement to code a join condition.

table A

field1

field2

field3

fielda

fieldb

table B

field1

field2

fieldc

i need to retrieve values from these tables in such a way that

table A-field1 = table B-field1 and

table A-field2 = table B-field2 and

table A-fielda = '100'

table A-fieldb = '200'

table B-fieldc IN sel_option.

TABLE A contains less entries compared to TABLE B. hence i coded the join condition like this

SELECT table_Afield1 table_Afield2 table_A~field3

table_B~fieldc INTO TABLE t_jointable

FROM table_B

INNER JOIN table_A

ON table_Afield1 = table_Bfield1

AND table_Afield2 = table_Bfield2

WHERE

table_A~fielda = '100'

AND table_A~fieldb = '200'

AND table_B~fieldc IN s_selop.

it doesn't work. did i miss something. your help would be appreciated.

Thanks,

kranthi.

4 REPLIES 4

Former Member
0 Kudos
76

This can be because you are using INNER join. Check if entries are present in Table A also. If the entries are not present in table A but only in table B, this will not pick up any details in output internal table.

former_member188685
Active Contributor
0 Kudos
76

I think COde is ALrite.

But What is ur problem exactly.

are u getting some thing or not.

Check the Data in table once .

regards

vijay

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
76

It look pretty good to me.... I would swap the FROM INNER JOIN. Are you sure that fielda and fieldb are stored like "100" or "200" in the database. Could they be being stored as "0100" or something like that?



SELECT table_A~field1 table_A~field2
       table_A~field3 table_B~fieldc 
         INTO TABLE t_jointable
<b>         FROM table_A
                 INNER JOIN table_B</b>
                   ON table_A~field1 = table_B~field1
                  AND table_A~field2 = table_B~field2
                     WHERE table_A~fielda = '100'
                       AND table_A~fieldb = '200' 
                       AND table_B~fieldc IN s_selop.


Regards,

Rich Heilman

former_member188685
Active Contributor
0 Kudos
76

There is nothing wrong with the code.

I think check once your Data in database.

Regards

vijay