I want to write a query that concatenates the countries that are in the same mountain. So, in the result table, I'll have one a time the name of the mountain and a column which is named countries with the concatenated countries separated with commas.
Asked
Active
Viewed 29 times
-2
-
2Give you give an example of how the final output should look? What do you want to do with province? – Phaelax z Sep 09 '21 at 13:56
-
3Hint: `group_concat`. – jarlh Sep 09 '21 at 13:56
-
1Assuming you are using MYSQL a quick search on google brought back [this thread](https://stackoverflow.com/questions/3492539/mysql-multiple-row-as-comma-separated-single-row). I think you want to use group_concat – Bee_Riii Sep 09 '21 at 13:56
-
2Does this answer your question? [MySQL Results as comma separated list](https://stackoverflow.com/questions/662207/mysql-results-as-comma-separated-list) – JNevill Sep 09 '21 at 13:57
-
yes, you can use GROUP_CONCAT – Rajeev Singh Sep 15 '21 at 10:04
-
Please provide enough code so others can better understand or reproduce the problem. – Community Sep 15 '21 at 12:10
1 Answers
0
SELECT GROUP_CONCAT (Country) as "country"
FROM table_name group by Mountain;
Use GROUP_CONCAT you can learn more about it here:- GROUP_CONCAT

rahul yadav
- 46
- 5