This join always selects all records from the second table (right table) and then selects matching records from the first table (left table). If no records found then a blank line is created for the respected second table records. Hence it is similar to left outer logic with the right or second table. It is very much useful when we need to fetch second table data based on the first 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 sflight AS b
RIGHT OUTER JOIN spfli AS a "Right join table
ON b~carrid = a~carrid AND
b~connid = a~connid
INTO TABLE @DATA(itab)
WHERE a~carrid = @p_carrid.
cl_demo_output=>display( itab ).
Now we need to fetch second table data based on the first table records. We don't need to fetch mismatching records into the output. Hence the second table must be under right outer 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
RIGHT 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 ).
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 sflight AS b
RIGHT OUTER JOIN spfli AS a "Right join table
ON b~carrid = a~carrid AND
b~connid = a~connid
INTO TABLE @DATA(itab)
WHERE a~carrid = @p_carrid.
cl_demo_output=>display( itab ).
Now we need to fetch second table data based on the first table records. We don't need to fetch mismatching records into the output. Hence the second table must be under right outer 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
RIGHT 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 ).
No comments:
Post a Comment