REPORT demo_select_left_outer_join .
DATA: BEGIN OF wa, carrid TYPE scarr-carrid, carrname TYPE scarr-carrname, connid TYPE spfli-connid, cityfrom TYPE spfli-cityfrom, END OF wa, itab LIKE SORTED TABLE OF wa WITH NON-UNIQUE KEY carrid. SELECT s~carrid s~carrname p~connid p~cityfrom INTO CORRESPONDING FIELDS OF TABLE itab FROM scarr AS s LEFT OUTER JOIN spfli AS p ON s~carrid = p~carrid AND p~cityfrom = 'FRANKFURT'. LOOP AT itab INTO wa. WRITE: / wa-carrid, wa-carrname, wa-connid, wa-cityfrom. ENDLOOP.
Program çıktısı aşağıdaki gibidir. Görüldüğü üzere FRANKFURT ile eşleşmeyen satırlar da çağrılmış durumda.
Aynı örnek INNER JOIN ile yapıldığında ise FRANKFURT'la eşleşmeyen satırlar gözükmeyecektir.
REPORT demo_select_inner_join .
DATA: BEGIN OF wa,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH NON-UNIQUE KEY carrid.
SELECT s~carrid s~carrname p~connid p~cityfrom
INTO CORRESPONDING FIELDS OF TABLE itab
FROM scarr AS s
INNER JOIN spfli AS p ON s~carrid = p~carrid AND
p~cityfrom = 'FRANKFURT'.
LOOP AT itab INTO wa.
WRITE: / wa-carrid, wa-carrname, wa-connid, wa-cityfrom.
ENDLOOP.
Program çıktısı aşağıdaki gibidir.
No comments:
Post a Comment