Wednesday, May 22, 2013

STRSQL AS400 "LIKE" statement

Hi all,

Here's a quick example of how to use the LIKE statement in AS400 SQL.  You can select from a file where a certain fields contain a wild card of a certain value.  For example:

SELECT * FROM FILE1 WHERE FIELD1 LIKE '%ABC%'

The above statement will select all records where FIELD1 contains the value "ABC" anywhere within the field data.  (i.e. "123ABC123", "ABC123", "123ABC")

Each of these records will appear in the query.

Enjoy!

2 comments:

  1. Need help with like sentence:

    SELECT * FROM PZLIBDRA/VEN02BK V
    WHERE V.PDNOM LIKE '%'||&NOM||'%'

    Error: the column madecor not exists in tables.

    ReplyDelete
  2. LIKE('%'||TRIM(Name_field)||'%')

    ReplyDelete