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

sql_cond - EXISTS subquery

Other versions: 7.31 | 7.40 | 7.54

Syntax


... EXISTS subquery ...

Effect

This expression can be created using any subquery. It is true if the results set of the subquery contains at least one row.


Example

Extracts all available flights leaving from New York from the database table SFLIGHT to the internal table free_flights.

DATA city         TYPE spfli-cityfrom VALUE 'NEW YORK'. 

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