By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,515 Members | 1,682 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,515 IT Pros & Developers. It's quick & easy.

pattern matching

P: n/a
Is there any way to do the following pattern match in db2?

LIKE '[CK]ars[eo]n' searches for Carsen, Karsen, Carson, and Karson
(Carson).

In other words, the brackets around CK will match anything with a C or
K in the first character.

Thanks.
Nov 21 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Nov 21, 3:10 pm, jrh...@hotmail.com wrote:
Is there any way to do the following pattern match in db2?

LIKE '[CK]ars[eo]n' searches for Carsen, Karsen, Carson, and Karson
(Carson).

In other words, the brackets around CK will match anything with a C or
K in the first character.

Thanks.
For simple patterns you can use something like:

select * from T where substr(mycol,1,1) in ('C','K') and substr(mycol,
2,3) = 'ers' ...

For a more general approach, you might find the following article by
Knut Stolze interesting:

http://www.ibm.com/developerworks/db...301stolze.html

/Lennart
Nov 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.