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 - Relational operators

Other versions: 7.31 | 7.40 | 7.54

Syntax


... col1 operator {dobj} 
                | {col2}
                | {[ALL|ANY|SOME] subquery} ...

Effect

The logical expression compares the content of the column col1, corresponding to the relational operator operator, with the content of one of the following operands:

  • An ABAP data object dobj as a host variable
  • Another column col2 of a database table specified after a FROM In this case col2 must be specified using the column selector as dbtab~comp or tabalias~comp.

The following table shows the possible relational operators.

Operator Meaning
=, EQ True, if the content of col1 is the same as the content of the second operand.
<>, NE True, if the content of col1 is different to the content of the second operand.
<, LT True, if the content of col1 is less than the content of the second operand.
>, GT True, if the content of col1 is greater than the content of the second operand.
<=, LE True, if the content of col1 is less than or equal to the content of the second operand.
>=, GE True, if the content of col1 is greater than or equal to the content of the second operand.

You should note the following when using these operators:

  • If the second operand is a column of a database table specified after FROM, the types and length of both operators must be equal, otherwise the result depends on the database system.
  • In large/small comparisons with character-type columns the result can depend on the code page used by the database system.


Note

Outside of classes, the obsolete relational operators ><, =<, => may also still be used.


Example

Read overbooked flights.

TYPES: BEGIN OF sflight_tab_type, 
         carrid TYPE sflight-carrid, 
         connid TYPE sflight-connid, 
         fldate TYPE sflight-fldate, 
       END OF sflight_tab_type. 

DATA sflight_tab TYPE TABLE OF sflight_tab_type. 

SELECT carrid connid fldate 
       FROM sflight 
       INTO CORRESPONDING FIELDS OF TABLE sflight_tab 
       WHERE seatsocc > sflight~seatsmax.