se_1581
asked on
DB2 LOCATE & SUBSTR
Hi,
I'm trying to extract the state from the address fields. the format is this: street, ST where street is the name of the street and ST is the state initials from 2 letters. most of the time the following code works but there are instances where it returns the 2 letters starting with the second position.
code: select substr(column, locate(',','column')+2,2) from table
example where it doesn't work. Sturgis, MI . for this example it returns the string 'tu'
Any idea why is acting like this?
Thanks.
I'm trying to extract the state from the address fields. the format is this: street, ST where street is the name of the street and ST is the state initials from 2 letters. most of the time the following code works but there are instances where it returns the 2 letters starting with the second position.
code: select substr(column, locate(',','column')+2,2) from table
example where it doesn't work. Sturgis, MI . for this example it returns the string 'tu'
Any idea why is acting like this?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks,
Stelian