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

Help in join

Former Member
0 Likes
469

Hi

i want to do join and i have error:

SELECT a~app a~appr b~atid b~attal
    INTO CORRESPONDING FIELDS OF TABLE  app_att_tab
    FROM ( Z_app as a
    INNER JOIN Zd_d_apat ON a~userid = iv_userid ).

Iv_user id is parameter that i get in the input FM

the error is :

You cannot compare with "IV_USERID". Each comparison in the ON

condition must contain a field from the RH table.

Regards

Joy

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
396

the ON section is used to connect the two tables in the SELECT statement, so you should provide the fields which connect the two. For example, if A has a user id field and so does B, then your ON statement should look like this.

on a~user_id = b~user_id

Then you can do your restrictions in the WHERE clause like this.

where a~user_id = iv_user_id.

So the finished SELECT statement might look like this.

SELECT a~app a~appr b~atid b~attal
    INTO CORRESPONDING FIELDS OF TABLE  app_att_tab
    FROM ( Z_app as a
    INNER JOIN Zd_d_apat as b
                      ON a~userid = b~user_id )
                                   where a~user_id = iv_user_id.

Cheers,

Rich Heilman

1 REPLY 1
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
397

the ON section is used to connect the two tables in the SELECT statement, so you should provide the fields which connect the two. For example, if A has a user id field and so does B, then your ON statement should look like this.

on a~user_id = b~user_id

Then you can do your restrictions in the WHERE clause like this.

where a~user_id = iv_user_id.

So the finished SELECT statement might look like this.

SELECT a~app a~appr b~atid b~attal
    INTO CORRESPONDING FIELDS OF TABLE  app_att_tab
    FROM ( Z_app as a
    INNER JOIN Zd_d_apat as b
                      ON a~userid = b~user_id )
                                   where a~user_id = iv_user_id.

Cheers,

Rich Heilman