DB2 Select - Replace STATES with two character code

Posted by user2528724 on Stack Overflow See other posts from Stack Overflow or by user2528724
Published on 2013-06-27T15:26:59Z Indexed on 2013/06/27 16:21 UTC
Read the original article Hit count: 218

Filed under:

I have a Users Table where it stores city, state and country along with other Users attributes. The states are stored as California, Alabama and so forth. Now I want to retrieve the user information for certain records but the state should get translated to two digit code. Say 'California' should be 'CA'. How should I go about doing this.

I was thinking to create a mapping table for state names with there abbreviation and then use some sort of replace function to do it.

Any ideas ?

© Stack Overflow or respective owner

Related posts about db2