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

Inner Join Select query

Former Member
0 Likes
761

hello all,

Below is a inner join query

SELECT aebeln aebelp apackno bzekkn b~ps_psp_pnr

FROM ( ( ekpo AS a INNER JOIN ekkn AS b

ON aebeln = bebeln

AND aebelp = bebelp )

INNER JOIN prps AS c

ON bps_psp_pnr = cpspnr )

INTO TABLE t_wbspo

WHERE a~ebeln IN s_ebeln

AND c~psphi IN s_psphi

AND stufe = c_task.

I want to modify this select and put one more join on ekkn-aufnr

and aufk-afunr .

Now for this i write the below code

SELECT aebeln aebelp apackno bzekkn bps_psp_pnr baufnr

FROM ( ( ( ekpo AS a INNER JOIN ekkn AS b

ON aebeln = bebeln

AND aebelp = bebelp )

INNER JOIN prps AS c

ON bps_psp_pnr = cpspnr )

INNER JOIN aufk AS d

ON baufnr = daufnr )

INTO TABLE t_wbspo

WHERE a~ebeln IN s_ebeln

AND c~psphi IN s_psphi

AND d~aufnr IN s_aufnr

AND stufe = c_task.

By the above way does it puts a join on ekkn-aufnr and aufk-aufnr ?

Is the above way the right way to do it ?

Please confirm

regards

3 REPLIES 3
Read only

Former Member
0 Likes
591

Hey,

You can try your code it is the right way to join the table and it does join on ekkn-aufnr and aufk-aufnr

Regards,

Midhun Abraham

Read only

Former Member
0 Likes
591

Hello Bhanu,

Do you face any performance issue? Query looks good now, further you can refer to following threads to know more on JOIN-

http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm

Thank You,

Nishikant Kumbhar.

Read only

Former Member
0 Likes
591

Hello Bhanu,

After your code changes you can check for SQL trace to know which one is giving better result.

Thank You,

Nishikant Kumbhar.