‎2008 Sep 01 8:05 AM
Hi in my select query in the where codn i have to give fields from different tables.How to write it?
‎2008 Sep 01 8:08 AM
Hi Hema,
Please go through the following information :
Specifying Two or More Database Tables as a Left Outer Join
In an inner join, a line from the left-hand database table or join is only included in the selection if there is one or more lines in the right-hand database table that meet the ON condition <cond>. The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.
Example :
SELECT p~carrid p~connid f~fldate b~bookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON p~carrid = f~carrid AND
p~connid = f~connid )
INNER JOIN sbook AS b ON b~carrid = f~carrid AND
b~connid = f~connid AND
b~fldate = f~fldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
f~seatsmax > f~seatsocc.Regards,
Swapna.
‎2008 Sep 01 8:07 AM
Hi Hema,
loop the tables and use SELECT query in that .
But this will be performance issue.
Best regards,
raam
‎2008 Sep 01 8:08 AM
Hi Hema,
Please go through the following information :
Specifying Two or More Database Tables as a Left Outer Join
In an inner join, a line from the left-hand database table or join is only included in the selection if there is one or more lines in the right-hand database table that meet the ON condition <cond>. The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.
Example :
SELECT p~carrid p~connid f~fldate b~bookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON p~carrid = f~carrid AND
p~connid = f~connid )
INNER JOIN sbook AS b ON b~carrid = f~carrid AND
b~connid = f~connid AND
b~fldate = f~fldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
f~seatsmax > f~seatsocc.Regards,
Swapna.
‎2008 Sep 01 8:09 AM
Hi I assume you are writing select quiry for inner join on multiple DB tables. In that case you need to write as some thing as below.
maramatnr in s_matnr AND marcwerks eq p_werks.....
Hope this will help,
Rama.
‎2008 Sep 01 8:11 AM
hii
you can use JOIN statement for different fields in where conditions
SELECT
likp~vbeln
likp~vstel
likp~lfart
likp~erdat
likp~wadat
likp~kunnr
lips~matnr
lips~lfimg
lips~meins
INTO TABLE itab FROM likp
INNER JOIN lips ON (lips~vbeln = likp~vbeln)
inner join vbuk on (likp~vbeln = vbuk~vbeln)
WHERE likp~erdat IN s_erdat
and likp~vstel in p_vstel
and likp~lfart in p_lfart
and vbuk~fkstk ne 'C'.regards
twinkal
‎2008 Sep 01 9:01 AM
HI,
The solution of your problem is JOIN .
u can use join to take field from different table
hope it will help you.............