Get the remainder of SUBSTRING_INDEX I have a problem regarding SUBSTRING_INDEX. 

 

As the image shows, I can get the city by 

SELECT SUBSTRING_INDEX(location,'-',1)) FROM my_table


However for the state_country column, I need the value which is after the '-'.

Is there a way to get that value and add it to the state_country column?

Thanks in advance.
To resolve this, I did the following:

Sample data table.

CREATE TABLE city_state
(
  location VARCHAR(100),
  city VARCHAR(100)
);


Sample data.

INSERT INTO city_state VALUES ('Minneapolis - Minnesota', 'Minneapolis'); -- note, space between hyphen and Minnesota
INSERT INTO city_state VALUES ('Orange County - CA', 'Orange County');
INSERT INTO city_state VALUES ('Denver - Colorado', 'Denver');
INSERT INTO city_state VALUES ('Dowingtown-Pennsylvania', 'Downingtown');  -- note, no space between "Downington" and "Pennsylvania" - also,
INSERT INTO city_state VALUES ('Manhattan-New York', 'Manhattan');
INSERT INTO city_state VALUES ('Ventura-California', 'Ventura');
INSERT INTO city_state VALUES ('Winston-Salem-North Carolina', 'Winston-Salem');  -- note, compound place name, i.e. Winston-Salem


For the Winston-Salem example, check here!

As pointed out by @Dudu Markovitz, you have to select from the last hyphen.

SELECT SUBSTRING_INDEX( location, '-', -1) FROM city_state;


But, there are also fields with spaces between the hyphen and those without, so a more complete answer would be:

SELECT TRIM(SUBSTRING_INDEX( location, '-', -1)) FROM city_state;

Minnesota
CA
Colorado
Pennsylvania
New York
California
North Carolina


Note, no spaces preceding (or following) the location name.