AS ABAP Release 758, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP - Programming Language → Processing External Data → ABAP Database Access → ABAP SQL → ABAP SQL - Read Access → SELECT, clauses →
SELECT, WHERE
Syntax
... WHERE sql_cond ...
Effect
The addition WHERE restricts the number of rows that are included in the result set by the statement SELECT of a query by using a logical expression sql_cond. A row is only included in the result set if the logical expression is true.
Except for columns of type STRING, RAWSTRING, or GEOM_EWKB, or LCHR and LRAW, all columns of the data sources specified after FROM can usually be evaluated in the WHERE condition of a query. Special rules apply to some logical expressions. The columns do not necessarily have to be a part of the result set.
Implicit ABAP SQL client handling applies to the WHERE clause. The client column of a client-dependent data source cannot be used as an operand in the WHERE condition.
Hints
Example
Reading of all objects in the ABAP keyword documentation from the table DOKIL using a suitable WHERE condition. Messages of the code inspector regarding the bypassing of the table buffer are suppressed using pseudo comments.
SELECT FROM dokil
FIELDS object, langu
WHERE id = 'SD' AND
typ = 'E' AND
( object LIKE 'ABAP%' OR
object LIKE 'ABEN%' OR
object LIKE 'DYNP%' ) AND
( langu = 'D' OR langu = 'E' ) "#EC CI_GENBUFF
ORDER BY object, langu
"#EC CI_BYPASS
INTO TABLE @FINAL(dokil_tab).
Executable Examples