db2 sql pattern matching

Posted by Jitesh on Stack Overflow See other posts from Stack Overflow or by Jitesh
Published on 2010-04-07T15:54:40Z Indexed on 2010/04/07 16:13 UTC
Read the original article Hit count: 266

Filed under:
|

I have a table in db2 which has the following fields

  • int xyz;
  • string myId;
  • string myName;

Example dataset

xyz  |  myid         | myname
--------------------------------
1    |  ABC.123.456  | ABC
2    |  PRQS.12.34   | PQRS
3    |  ZZZ.3.2.2    | blah

I want to extract the rows where myName matches the character upto "." in the myId field. So from the above 3 rows, I want the firs 2 rows since myName is present in myId before "."

How can I do this in the query, can I do some kind of pattern matching inside the query?

© Stack Overflow or respective owner

Related posts about sql

Related posts about db2