Wildcards in DB2 SQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nikhilk
    New Member
    • Jan 2010
    • 1

    Wildcards in DB2 SQL

    Hello,

    I am new to this forums and new to DB2 too.

    I have a requirement here. Does DB2 support wildcards like [charlist], [^charlist] or [!charlist] other than '_' and '%'?

    Here are the tables values:
    1234
    12345
    12346A
    1234AB
    1234ABCD
    AB1234CD
    123456AB

    Can somebody help me write a query to match for '1234' to get only these values:
    1234
    1234AB
    1234ABCD
    AB1234CD

    Any help is greatly appreciated.

    Thanks,
    Nikhil
  • hitendrap
    New Member
    • Sep 2009
    • 9

    #2
    Ofcourse DB2 supports wildcard chars,

    use % with LIKE clause in case to CHAR datatype

    for eg. SELECT * FROM your_table WHERE your_column LIKE '%1234%'

    this will search matches for substring 1234 anywhere in the string & you will get result as desired:
    1234
    1234AB
    1234ABCD
    AB1234CD

    Comment

    Working...