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 - subquery 

sql_cond - EXISTS subquery

Other versions: 7.31 | 7.40 | 7.54

Syntax


... [NOT] EXISTS subquery ...

Effect

This expression can be formed with any subquery. It is true if the result set for the subquery contains (does not contain) at least one row.


Example

Reading all free flights leaving from New York from the SFLIGHT database table to the free_flights internal table.

DATA free_flights TYPE TABLE OF sflight. 

SELECT * 
       FROM sflight AS s 
       INTO TABLE free_flights 
       WHERE seatsocc < s~seatsmax AND 
             EXISTS ( SELECT  * 
                             FROM  spfli 
                            WHERE carrid   =  s~carrid AND 
                                  connid   =  s~connid AND 
                                  cityfrom = 'NEW YORK' ).