cancel
Showing results for 
Search instead for 
Did you mean: 

Which Join should I use when connecting 2 tables

walkerist
Participant
0 Kudos

Table PAPERVERSIONS

Table PAPERAUTHORS

I was trying to get the display the Paper Author but not familiar with SELECT JOIN on ABAP

Expected output is to dispaly Schmee Maluche

Here's my code:

SELECT SINGLE paperversions~paper_id, paperauthors~paper_id<br>  

FROM paperversion<br>    

INNER JOIN paperauthors<br>     

ON paperversions~paper_id = paperauthors~paper_id<br>  

INTO  @l_test<br>  

WHERE paper_author EQ  @ "MY CUSTOM FIELD XXX"
Sandra_Rossi
Active Contributor
0 Kudos

Why do you use WHERE paper_author = ... if the author is what you're looking for.

Do you mean WHERE paper_id = ... ? (and then you should have SELECT paper_author...)

Please clarify...

walkerist
Participant
0 Kudos

sandra.rossi apologies for the confusion. I would like to display the paper_author

Sandra_Rossi
Active Contributor
0 Kudos

I guess the current answers solve your question, please mark one as accepted or vote accordingly.

Accepted Solutions (1)

Accepted Solutions (1)

anujawani2426
Active Participant

Hi,

Please try below code. Below query will display paper id and corresponding paper author. if you just want to print paper author then write only paper_author in select single.

SELECT SINGLE paperversions~paper_id, paperauthors~paper_author  

FROM paperversions    

INNER JOIN paperauthors     

ON paperversions~paper_id = paperauthors~paper_id  

INTO  @l_test  

WHERE paper_author EQ  @ "MY CUSTOM FIELD XXX"

Regards,

Anuja Kawadiwale

walkerist
Participant
0 Kudos

Hello this is my current code but the paper_author doesn't appear.

SELECT SINGLE paper_author  

FROM paperversions    

INNER JOIN paperauthors     

ON paperversions~paper_id = paperauthors~paper_id  

INTO  @l_test  

WHERE paper_author EQ  @ "MY CUSTOM FIELD XXX"
anujawani2426
Active Participant

Hi,

If you want to print only paper_autor which is present in paperauthors table then you don't need to join both tables.

You can directly fetch paper_author from paperauthors table.

SELECT SINGLE paper_author  

FROM paperauthors     

INTO  @l_test  

WHERE paper_author EQ  @ "MY CUSTOM FIELD XXX"

Answers (1)

Answers (1)

venkateswaran_k
Active Contributor

Hi

If you use INNER JOIN - then both the tables should have that ID (you passed in where clause) - else no rows will be displayed

If you use LEFT OUTER JOIN - then the table on left side you used, it will display all rows that matches the id that you pass in where clause ( even if auther table does not contain that id)