DB2 – Case Insensitive LIKE

db2likestring-searching

Is there a way to do a LIKE operation in DB2 against a varchar column in a case insensitive way, without changing the underlying column definition?

Or is there a workaround like SELECT * FROM mytable WHERE mycolumn LIKE '%string%' OR mycolumn LIKE '%STRING%' that would work?

Best Answer

No. Assuming Db2 for LUW, you can choose a case-insensitive collating table, but only at the database creation time.

You'll have to standardise the case for comparison, with obvious performance implications:

SELECT * FROM mytable WHERE LCASE(mycolumn) LIKE '%string%'