Skip to Content
0
Former Member
May 14, 2008 at 04:29 PM

Is this SQL Statement correct?

47 Views

Hi All,

I want to avoid a subquery and created an INNER JOIN, could anyone tell me whether they are the same or different from the given below SQL statment?. The internal table is already defined etc.

Inner Join

SELECT abegda aendda aobjid asobid b~sobid

FROM hrp1001 AS a

INNER JOIN hrp1001 AS b ON aobjid = bobjid AND

b~subty = 'A008' AND

b~sclas = 'P'

INTO TABLE itab_allper

WHERE asubty = 'A003' AND asclas = 'O' and a~endda = '99991231'.

Equivalent in Subquery

SELECT abegda aendda aobjid asobid b~sobid INTO TABLE itab_allper

FROM hrp1001 as a

WHERE a~subty = 'A003' and

a~sclas = 'O' and

a~objid in (SELECT objid FROM HRP1001 as b

WHERE b~subty = 'A008' and

b~sclas = 'O').

Also if I want to display all columns based on objid that are not matching from table b, should I put LEFT OUTTER JOIN instead of INNER JOIN.

Thanks in advance.

Alex.