ABAP Keyword Documentation →  ABAP − Short Reference → 

SELECT - Short Reference

Reference

Syntax

SELECT { { SINGLE [FOR UPDATE] }
       | { [DISTINCT] { }      } }
       { *
       | { {col1|aggregate( [DISTINCT] col1 )} [AS a1]
           {col2|aggregate( [DISTINCT] col2 )} [AS a2]  ... }
       | (column_syntax) }
       FROM { { {dbtab [AS tabalias]}
              | { [(] {dbtab_left [AS tabalias_left]} | join
                      {[INNER] JOIN}|{LEFT [OUTER] JOIN}
                      {dbtab_right [AS tabalias_right] ON join_cond} [)]}
              | (dbtab_syntax) [AS tabalias] }
              [CLIENT SPECIFIED]
              [UP TO n ROWS]
              [BYPASSING BUFFER]
              [CONNECTION con|(con_syntax)] }
       { { INTO {[CORRESPONDING FIELDS OF] wa}|(dobj1, dobj2, ...) }
       | { INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab
                          [PACKAGE SIZE n] } }
       [ CREATING {  READER|LOCATOR FOR { COLUMNS col1 col2 ... }
                                 | { ALL [OTHER] [BLOB|CLOB] COLUMNS }
                    [READER|LOCATOR FOR ...] }
                | {  (crea_syntax) } ]
       [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
       [GROUP BY {col1 col2 ...}|(column_syntax)]
       [HAVING sql_cond]
       [ORDER BY { {PRIMARY KEY}
                 |{{{col1|a1} [ASCENDING|DESCENDING]}
                   {{col2|a2} [ASCENDING|DESCENDING]}
                   ... }
                 | (column_syntax) }].
  ...
[ENDSELECT.]


Effect

This statement reads data from one or more database tables into data objects. If the result 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

Specification of the rows:

Specification of the columns

Specification of the database table(s):

Specifying the target area:

Specifying of a condition:

Specification of a grouping:

Specification of a sorting: