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