Entering content frame

IN Predicate (in_predicate) Locate the document in its SAP Library structure

The IN predicate (in_predicate) checks whether a value or a value list is contained in a specified set of values or value lists.

Syntax

<in_predicate> ::=
  <expression> [NOT] IN <subquery>
| <expression> [NOT] IN <expression_list>
| <expression_list> [NOT] IN <subquery>
| <expression_list> [NOT] IN (<expression_list>,...)

Explanation

The subquery (subquery) must supply a result table (see Result Table Name) that contains the same number of columns as the number of values specified by the expression (expression) on the left-hand side of the IN operator.

Each value list specified on the right-hand side of the IN operator must contain the same number of values as specified in the value list on the left-hand side of the IN operator.

·        x [NOT] IN S, whereby x <expression> and S <subquery> or <expression_list>
The value x and the values in S must be comparable.

·        x [NOT] IN S, whereby x <expression_list> with the values x1, x2, ..., xn and S <subquery> (set of value lists s) or (<expression_list>,...) (Range of values lists s) with the value lists s: s1, s2, ..., sn
A value xm must be comparable with all values sm.
x=s is true if xm=sm, m=1,...,n
x=s is false if there is at least one m for which xm=sm is false
x=s is undefined if there is no m for which xm=sm is false and there is at least one m for which xm=sm is undefined.

The entry '------' in the list below means that no statement can be made if only the result of the comparison with one s is known.

 

Result of the x IN S Function

x=s is true for at least one s

true

x=s is true for all s

true

S contains NULL values and x=s is true for the remaining s

true

S is empty

false

x=s is false for at least one s

------

x=s is false for all s

false

S contains NULL values and x=s is false for the remaining s

undefined

x=s is not true for any s and is undefined for at least one value s

undefined

x NOT IN S has the same result as NOT(x IN S)

Example

SELECT title, firstname, name
  FROM customer
    WHERE title IN ('Mr','Mrs')

Choosing all customers who are natural persons (not companies):

TITLE

FIRSTNAME

NAME

Mrs

Jenny

Porter

Mr

Peter

Brown

Mrs

Rose

Brian

Mrs

Mary

Griffith

Mr

Martin

Randolph

Mrs

Sally

Smith

Mr

Mike

Jackson

Mrs

Rita

Doe

Mr

George

Howe

Mr

Frank

Miller

Mrs

Susan

Baker

Mr

Joseph

Peters

Mr

Antony

Jenkins

 

 

Leaving content frame