Jump to content
Sign in to follow this  
Prodjex

MYSQL MySQL Trim

Recommended Posts

I have a column within my MySQL table that holds city and states for records.

The dataset looks like the following:

Clay County, AL  
Cleburne County, AL
Coffee County, AL
Colbert County, AL                    
Conecuh County, AL                   
Coosa County, AL                 
Covington County, AL

I need to just select the state name for all of the records.  Since I know this is not user input and the data is all clean/structured as above I can trim off what I don’t need with the following command:

select right(trim(cityStateField), 2);

This then returns the needed results with just the state abbreviation:

AL
AL
AL
AL
AL
AL
AL

The post MySQL Trim appeared first on Kansas City Web Consulting | Kansas City Web Development.

View the full article

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×