I have a column in my database name location which have city name and country name in this format New york,America
. I want to run a select query with the explode function like which we use in php to separate values like this
so that i can get comma , separated values
select explode(",",location) from address;
Also with the alias of city column holding New York and alias of country holding value of America. So that i can use them in my store procedure and insert this values in references table in the columns city and country
You can not really "explode" or split on all comma's, but you can split a string on any comma using SUBSTRING_INDEX
.
SELECT SUBSTRING_INDEX('New york,America', ',', 1);
-> New york