Skip to content

ABAP Keyword Documentation →  ABAP − Short Reference 

SELECT - Short Reference

Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


SELECT { { SINGLE [FOR UPDATE] } 
       | { [DISTINCT] { }      } }
       { *
       | { ..., data_source~*, ...,
           col| aggregate( [DISTINCT] col )|sql_exp} [AS alias], ... }
       | (column_syntax)
       FROM { { {data_source [AS tabalias]}
              | { [(] {data_source [AS tabalias]}|join
                    {[INNER] JOIN}|{LEFT|RIGHT [OUTER] JOIN}
                       {data_source [AS tabalias]}|join ON join_cond [)] }
              | (source_syntax) [AS tabalias] }
              [ {USING CLIENT clnt}
              | {CLIENT SPECIFIED [entity1~clnt] [, entity2~clnt] ...} ] }
       [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
       [GROUP BY {col1| sql_exp1, col2|sql_exp2, ...}|(column_syntax)]
       [HAVING sql_cond]
       [ORDER BY { {PRIMARY KEY}
                 |{{{col1|a1} [ASCENDING|DESCENDING],}
                   {{col2|a2} [ASCENDING|DESCENDING],}
                   ... }
                 | (column_syntax) }].
       { { INTO {[CORRESPONDING FIELDS OF] wa}|(dobj1, dobj2, ...) }
       | { INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab
                          [PACKAGE SIZE n] }
       | { INTO @DATA(wa) }
       | { INTO TABLE @DATA(itab) [PACKAGE SIZE n] } }
       [ CREATING {  READER|LOCATOR FOR { COLUMNS col1 col2 ... }
                                 | { ALL [OTHER] [BLOB|CLOB] COLUMNS }
                    [READER|LOCATOR FOR ...] }
                | {  (crea_syntax) } ]
       [UP TO n ROWS]
       [BYPASSING BUFFER]
       [CONNECTION con|(con_syntax)]
  ...
[ENDSELECT.]

Effect

This statement reads data from one or more database tables into data objects. If the results set is not assigned in one step, a loop is opened which is closed using ENDSELECT. This loop provides the results in the target fields.

Additions

Specifies the rows

Specifies the columns as a SELECT list

Specifies the database table(s)

Specifies a condition

  • FOR ALL ENTRIES IN itab
    Enables a condition to be used after WHERE on all rows in an internal table itab.
  • WHERE sql_cond
    Restricts the results set using the condition sql_cond. The condition can consist of different relational expressions.

Specifies a grouping

Specifies a sort

Specifies the target area

Specifies additions