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: 

Combining two queries in one..

Former Member
0 Kudos
209

Hi,

Can someone tell me how to combine follwoing two queries in one so that it will increase performance..

SELECT single PLNNR from AFKO

into T1

WHERE AUFNR = '007200000100'.

SELECT single STATU from PLKO

into T2

WHERE PLNNR = T1.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
89

check out the JOIN option

SELECT single Fplnnr pSTATU

INTO (t1, t2)

FROM AFKO AS F INNER JOIN PLKO AS P

ON Fplnnr = Pplnnr

WHERE AUFNR = '007200000100'.

4 REPLIES 4

Former Member
0 Kudos
90

check out the JOIN option

SELECT single Fplnnr pSTATU

INTO (t1, t2)

FROM AFKO AS F INNER JOIN PLKO AS P

ON Fplnnr = Pplnnr

WHERE AUFNR = '007200000100'.

0 Kudos
89



data: statu type plko-statu.



select single statu into statu
       from afko
          inner join plko
             on afko~plnnr = plko~plnnr
                      where aufnr = '007200000100'.

Regards,

Rich Heilman

0 Kudos
89

oops....

sorry u cant use select single in a sub query

the syntax of a subquery is quite restricted...the link will give you the details...

but in any case....either u use joins or subqueries...i dont think there will be a major impact on performance in this particular case that you have specified.

regards,

PJ

Former Member
0 Kudos
89

using subqueries it is possible

select single statu from plko into t2 where plnnr in (select single plnnr from afko where aufnr eq '007200000100').

read about subqueries at this link...

http://help.sap.com/saphelp_erp2004/helpdata/en/dc/dc7614099b11d295320000e8353423/frameset.htm

regards,

PJ