0

DB column data is multiline data , now i need to get result in single line

DB : Mysql Table name :: master_countries

db data

so i want output in a single line comma delimited:

SELECT REPLACE(country, '\n' ,',')  FROM master_countries
1
  • Do you have linux or windows new lines? This thread might be useful, stackoverflow.com/questions/13273343/…. (I also would advise against this DB structure for this reason) Commented Aug 31, 2020 at 12:50

2 Answers 2

1

SELECT id,GROUP_CONCAT(country) FROM master_countries GROUP BY id;

Sign up to request clarification or add additional context in comments.

1 Comment

country has multiple values in it, OP is trying to split on new lines.
0

Try this :

SELECT REPLACE(country, '\r\n' ,',')  FROM master_countries

or

SELECT REPLACE(country, '\n\r' ,',')  FROM master_countries

4 Comments

in phpmyadmin choose export then csv then choose Columns separated with:|
The provide code doesn't change the DB data. It selects and alters on the fly.
ok , then whats the issue ? is it not working ? SELECT REPLACE(country, '\n' ,',') if not try to put also SELECT REPLACE(country, '\n\r' ,',')
I don't know, it is not my question. Just pointing out an issue with the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.