FOR ALL ENTRIES IN:不能使用聚合函数;关联字段的类型和长度必须一致;内表为空,则全表查询;
INNER JOIN:可以使用聚合函数;关联的字段类型长度可以不一致;内表为空,查询无果;
DATA: lt_spfli TYPE TABLE OF spfli.
* Case 1: 内表为空, for all entries in时将sflight表记录全部查询出来
SELECT * FROM sflight INTO TABLE @DATA(lt_sflight)
FOR ALL ENTRIES IN @lt_spfli
WHERE carrid = @lt_spfli-carrid.
* Case 2: inner join内表,查询符合条件的数据
" 该例中内表为空,所以查询失败
" 这种方法不会对结果进行去重;for all entries会对结果去重
SELECT sflight~CARRID,
sflight~CONNID,
sflight~FLDATE
FROM sflight
INNER JOIN @lt_spfli as itab
ON sflight~carrid = itab~carrid
INTO TABLE @DATA(lt_result).