Skip to content

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

sql_cond - AND, OR, NOT

Other versions: 7.31 | 7.40 | 7.54

Syntax


... sql_cond1 AND sql_cond2 AND sql_cond3 ...

... sql_cond1 OR sql_cond2 OR sql_cond3 ...

... NOT sql_cond ...

Effect

Any number of logical sql_cond expressions can be linked to make one logical expression using AND or OR and the result of a logical expression can be negated using NOT. The same rules apply as for general logical expressions. In particular an explicit use of parantheses is also possible.

For logical expressions, of which the result is unknown, the following additional rules apply:

  • The AND linking of two unknown expressions or one true expression with an unknown expression results in an unknown expression. The AND linking of a false expression with an unknown expression results in a false expression.
  • The OR linking of two unknown expressions or one false expression with an unknown expression results in an unknown expression. The OR linking of one true and one unknown expression results in a true expression.
  • The negation of an unknown expression with NOT results in an unknown expression.


Note

In particular, the expressions specified dynamically as (cond_syntax), are also possible as logical expressions within a link or negation.


Example

Read flights from Frankfurt to Los Angeles or San Francisco.

DATA spfli_tab TYPE TABLE OF spfli. 

SELECT * 
       FROM spfli 
       INTO TABLE spfli_tab 
       WHERE cityfrom = 'FRANKFURT' AND 
             ( cityto = 'LOS ANGELES' OR 
               cityto = 'SAN FRANCISCO' ).