Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Read Accesses →  SELECT →  SELECT - WHERE 

WHERE - sql_cond

Short Reference

Other versions: 7.31 | 7.40 | 7.54


 ... { {col1 {=|EQ|<>|NE|>|GT|<|LT|>=|GE|<=|LE} 
              { {dobj}
              | {col2}
              | {[ALL|ANY|SOME] subquery} }}
    | {col [NOT] BETWEEN dobj1 AND dobj2}
    | {col [NOT] LIKE dobj [ESCAPE esc]}
    | {col [NOT] IN (dobj1, dobj2 ...)}
    | {col [NOT] IN seltab}
    | {col IS [NOT] NULL}
    | {(cond_syntax)}
    | {EXISTS subquery}
    | {col [NOT] IN subquery} } ...


The logical expressions sql_cond in the WHERE condition are similar to the general logical expressions for control statements. They consist of relational expressions with relational operators and with predicate operators. The logical expressions of a WHERE condition can also be specified dynamically. Subqueries can be used too. Multiple relational expressions of a WHERE condition can be joined as one expression using AND or OR. A logical expression can be negated using NOT

Each individual relational expression of the WHERE condition must always contain at least one column col from one of the database tables or views listed after FROM as an operand. The same column names (comp, data_source~comp, tabalias~comp) can be specified for col as when single columns are specified in the SELECT list. No aggregate expressions, SQL expressions, or columns of the type STRING, RAWSTRING, LCHR, or LRAW can be specified.


For frequently used SELECT statements with an identical WHERE condition, an index. In WHERE conditions, the fields of the index should be expressed as equality comparisons and joined using the AND operator. All the fields of an index that are behind a field, for which a comparison other than = or EQ is specified in the WHERE clause, cannot be used for searching in the index.


sql_cond - Relational Operators

sql_cond - BETWEEN

sql_cond - LIKE

sql_cond - IN

sql_cond - IN seltab

sql_cond - NULL

sql_cond - (cond_syntax)

sql_cond - subquery

sql_cond - AND, OR, NOT