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

hi all

Former Member
0 Likes
922

hi

my question is : is it possible to have 'inner join' with 'select single' statement???

thanx

rocky

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
906

Hi

yes u can

You can read data from more than one database table in a single SELECT statement by using inner or left outer joins in the FROM clause.

The disadvantage of using joins is that redundant data is read from the hierarchically-superior table if there is a 1:N relationship between the outer and inner tables. This can considerably increase the amount of data transferred from the database to the application server. Therefore, when you program a join, you should ensure that the SELECT clause contains a list of only the columns that you really need. Furthermore, joins bypass the table buffer and read directly from the database. For this reason, you should use an ABAP Dictionary view instead of a join if you only want to read the data.

The runtime of a join statement is heavily dependent on the database optimizer, especially when it contains more than two database tables. However, joins are nearly always quicker than using nested SELECT statements.

reward points to all helpful answers

kiran.M

6 REPLIES 6
Read only

Former Member
0 Likes
907

Hi

yes u can

You can read data from more than one database table in a single SELECT statement by using inner or left outer joins in the FROM clause.

The disadvantage of using joins is that redundant data is read from the hierarchically-superior table if there is a 1:N relationship between the outer and inner tables. This can considerably increase the amount of data transferred from the database to the application server. Therefore, when you program a join, you should ensure that the SELECT clause contains a list of only the columns that you really need. Furthermore, joins bypass the table buffer and read directly from the database. For this reason, you should use an ABAP Dictionary view instead of a join if you only want to read the data.

The runtime of a join statement is heavily dependent on the database optimizer, especially when it contains more than two database tables. However, joins are nearly always quicker than using nested SELECT statements.

reward points to all helpful answers

kiran.M

Read only

0 Likes
906

yes...

check this sample..

select single avbeln bkunnr

into (lips-vbeln, vbak-kunnr)

from lips as a

inner join vbak as b

on ( bvbeln eq avgbel )

where avbeln eq bvbeln.

reward if it helps..

regards,

Omkar.

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
906

Hi,

YES this should not be a problem, make sure to give the WHERE clause in a such a way that you donot read more than one record from Database.

Regards,

Sesh

Read only

Former Member
0 Likes
906

Hi,

Yes,it is Possible.

Pls Check the Following Code,

TABLES: likp,lips,vbak.

SELECT SINGLE lipsvbeln vbakkunnr

FROM lips

INNER JOIN vbak

ON ( vbakvbeln EQ lipsvgbel )

INTO (lips-vbeln,vbak-kunnr)

WHERE lips~vbeln EQ likp-vbeln.

Regards,

Padmam.

Read only

Former Member
0 Likes
906

Here is a sample code...........

PARAMETERS: p_cityfr TYPE spfli-cityfrom,

p_cityto TYPE spfli-cityto.

DATA: BEGIN OF wa,

fldate TYPE sflight-fldate,

carrname TYPE scarr-carrname,

connid TYPE spfli-connid,

END OF wa.

DATA itab LIKE SORTED TABLE OF wa

WITH UNIQUE KEY fldate carrname connid.

SELECT ccarrname pconnid f~fldate

INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( ( scarr AS c

INNER JOIN spfli AS p ON pcarrid = ccarrid

AND p~cityfrom = p_cityfr

AND p~cityto = p_cityto )

INNER JOIN sflight AS f ON fcarrid = pcarrid

AND fconnid = pconnid ).

LOOP AT itab INTO wa.

WRITE: / wa-fldate, wa-carrname, wa-connid.

ENDLOOP.

Regards,

Pavan

Read only

Former Member
0 Likes
906

Hello,

U can use select single with Inner join

See the sample code

  • Fetch data by joining KNVV & KNA1 and based on selection criteria

<b> SELECT single akunnr bvkorg FROM kna1 AS a

INNER JOIN knvv AS b ON akunnr = bkunnr

INTO corresponding fields of wa_knvv

WHERE b~vkorg = p_vkorg.</b>

Regards,

LIJO JOHN.