2007 Aug 13 9:36 AM
hi
my question is : is it possible to have 'inner join' with 'select single' statement???
thanx
rocky
2007 Aug 13 9:39 AM
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
hi
my question is : is it possible to have 'inner join' with 'select single' statement???
thanx
rocky
2007 Aug 13 9:39 AM
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
2007 Aug 13 9:42 AM
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.
2007 Aug 13 9:41 AM
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
2007 Aug 13 9:42 AM
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.
2007 Aug 13 9:43 AM
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
2007 Aug 13 9:48 AM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |