Show TOC

Selection Tables in the WHERE ClauseLocate this document in the navigation structure

Use

The WHERE clause is an option of the Open SQL statements SELECT , UPDATE and DELETE , and is used to restrict the values read during database accesses .

To use a selection table in the WHERE clause, you write:

......... WHERE f IN seltab .

f is the name of a database column, and seltab is the selection table that is assigned to this field. The relevant Open SQL statement accesses only those rows of the database table, where the contents of field f meet the selection criteria stored in seltab .

        
REPORT demo_where_in_seltab.
        
DATA wa_carrid TYPE spfli-carrid.
        
SELECT carrid FROM spfli INTO wa_carrid WHERE carrid IN airline.
        
WRITE / wa_carrid.
        
ENDSELECT.
         

Selection table airline is linked to the CARRID column of database table SPFLI. The WHERE clause of the SELECT statement checks if the contents of the CARRID column meet the selection criteria stored in airline .

If the selection table is filled as follows:

SIGN

OPTION

LOW

HIGH

I

BT

DL

UA

E

EQ

LH

Then the database rows for all airlines between DL and UA except LH are read.