tags:

views:

17

answers:

1

I need to do a SELECT for a product_id where the length the product_id is 4 characters long and the last character can be any letter. I know the wildcard for selecting any letters but I don't know how to denote that it has to be the last character and that the product_ids I'm looking for must be 4 characters long.

Does that make sense?

+1  A: 

Have you tried RIGHT and standard LIKE? (There is a LEFT in DB2). If not, SUBSTR.

In DB2 you can use LENGTH

So hopefully

WHERE
    RIGHT(product_id, 1) LIKE [A-Z] AND LEN(product_id) = 4
gbn