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

Select query where codn

Former Member
0 Likes
783

Hi in my select query in the where codn i have to give fields from different tables.How to write it?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
752

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.

5 REPLIES 5
Read only

Former Member
0 Likes
752

Hi Hema,

loop the tables and use SELECT query in that .

But this will be performance issue.

Best regards,

raam

Read only

Former Member
0 Likes
753

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.

Read only

Former Member
0 Likes
752

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.

Read only

Former Member
0 Likes
752

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

Read only

Former Member
0 Likes
752

HI,

The solution of your problem is JOIN .

u can use join to take field from different table

hope it will help you.............