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

Other versions: 7.31 | 7.40 | 7.54

Syntax


... col [NOT] IN subquery ...

Effect

This expression can be formed using a scalar subquery subquery. It is true if the value for the col column is (not) contained in the scalar subquery.


Example

Reads the geographical latitude and longitude of a city from the database table SGEOCITY, where this city is the city of origin of a flight in the database table SPFLI.

PARAMETERS: carr_id TYPE spfli-carrid, 
            conn_id TYPE spfli-connid. 

DATA: city  TYPE sgeocity-city, 
      lati  TYPE p LENGTH 8 DECIMALS 2, 
      longi TYPE p LENGTH 8 DECIMALS 2. 

SELECT SINGLE city, latitude, longitude 
         FROM sgeocity 
         WHERE city IN ( SELECT cityfrom 
                               FROM spfli 
                              WHERE carrid = @carr_id AND 
                                     connid = @conn_id ) 
         INTO (@city, @lati, @longi).