ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP SQL → ABAP SQL - Operands and Expressions → ABAP SQL - SQL Conditions sql_cond → sql_cond - rel_exp for Statements
sql_cond - EXISTS
... EXISTS ( SELECT subquery_clauses [ UNION ...] ) ...
Checks the results set of a subquery. The relational expression is true when the results set of the
subquery defined by the clauses
contains at least one row. The expression is possible for any results sets that can be defined using
The language element
UNION can be
used to combine the results sets of multiple subqueries. In this case, special rules
query_clauses apply for specifying clauses.
Extracts all available flights leaving from New York from the database table SFLIGHT to the internal table
DATA city TYPE spfli-cityfrom VALUE 'NEW YORK'. SELECT * FROM sflight AS s WHERE seatsocc < s~seatsmax AND EXISTS ( SELECT 'X' FROM spfli WHERE carrid = s~carrid AND connid = s~connid AND cityfrom = @city ) INTO TABLE @DATA(free_flights).