Glauco Oliveira
Glauco Oliveira

Reputation: 21

How do I use substring in WHERE clause?

My expression in OpenSQL is:

SELECT * FROM  J_1BNFLIN  AS B
  WHERE SUBSTRING(REFKEY , 1 , 10 )

The substring portion of the where clause is not working. What am I doing wrong?

Upvotes: 1

Views: 16757

Answers (1)

József Szikszai
József Szikszai

Reputation: 5071

You can use LIKE in the WHERE condition. For example:

DATA: gv_refkey TYPE j_1bnflin-refkey.
gv_refkey = '123%'.
SELECT *
       INTO TABLE ...
       FROM j_1bnflin
       WHERE refkey LIKE gv_refkey.

This will select all entries where the field refkey starts with '123' (pls. note a % is used as wildcard)

Upvotes: 3

Related Questions