This join will select all records from the first table based on the where condition and then it will join the second table with matching condition. Here if it doesn't find any record on the second table, then also it will create single line (blank line) for the join. Left outer join always creates one line of the right table based on the left table.
PARAMETERS: p_carrid TYPE spfli-carrid.
SELECT a~carrid, a~connid, a~cityfrom, a~cityto,
a~fltime, a~deptime, a~arrtime,
b~fldate, b~price, b~currency, b~planetype
FROM spfli AS a
LEFT OUTER JOIN sflight AS b
ON b~carrid = a~carrid AND
b~connid = a~connid
INTO TABLE @DATA(itab)
WHERE a~carrid = @p_carrid.
cl_demo_output=>display( itab ).
There are number of blank lines on the right table or second table. Now we shall put on a where condition for the second table also.
PARAMETERS: p_carrid TYPE spfli-carrid,
p_curr TYPE sflight-currency.
SELECT a~carrid, a~connid, a~cityfrom, a~cityto,
a~fltime, a~deptime, a~arrtime,
b~fldate, b~price, b~currency, b~planetype
FROM spfli AS a
LEFT OUTER JOIN sflight AS b
ON b~carrid = a~carrid AND
b~connid = a~connid
INTO TABLE @DATA(itab)
WHERE a~carrid = @p_carrid
AND b~currency = @p_curr.
cl_demo_output=>display( itab ).
Now see the output. The blank lines have gone. The second table is populated based on the where condition. Here the join condition happens for both table's where condition. It means the only matching records are populated in the join.
PARAMETERS: p_carrid TYPE spfli-carrid.
SELECT a~carrid, a~connid, a~cityfrom, a~cityto,
a~fltime, a~deptime, a~arrtime,
b~fldate, b~price, b~currency, b~planetype
FROM spfli AS a
LEFT OUTER JOIN sflight AS b
ON b~carrid = a~carrid AND
b~connid = a~connid
INTO TABLE @DATA(itab)
WHERE a~carrid = @p_carrid.
cl_demo_output=>display( itab ).
There are number of blank lines on the right table or second table. Now we shall put on a where condition for the second table also.
PARAMETERS: p_carrid TYPE spfli-carrid,
p_curr TYPE sflight-currency.
SELECT a~carrid, a~connid, a~cityfrom, a~cityto,
a~fltime, a~deptime, a~arrtime,
b~fldate, b~price, b~currency, b~planetype
FROM spfli AS a
LEFT OUTER JOIN sflight AS b
ON b~carrid = a~carrid AND
b~connid = a~connid
INTO TABLE @DATA(itab)
WHERE a~carrid = @p_carrid
AND b~currency = @p_curr.
cl_demo_output=>display( itab ).
Now see the output. The blank lines have gone. The second table is populated based on the where condition. Here the join condition happens for both table's where condition. It means the only matching records are populated in the join.
No comments:
Post a Comment