Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you append a carriage return to a value in MySQL?

Tags:

mysql

I'm importing some restaurant information and have found that I'm missing the type of cuisine in the description field. How do I append a carriage return to a value?

This is what I have so far; I want the cuisine to go in on a new line:

select concat(field_id_20, '\r', 'french') from table
like image 417
jhowe Avatar asked Feb 16 '12 16:02

jhowe


1 Answers

If you want a new line, then you're looking for a \n newline rather than a carriage return.

SELECT CONCAT_WS('\n', field_id_20, 'french');

CONCAT_WS() concatentates all subsequent arguments with the first argument. So you could add multiple lines this way by doing:

SELECT CONCAT_WS('\n', field_id_20, 'french', 'german', 'indian');

Outputs:

CurrentValueFrom field_id_20
french
german
indian
like image 99
Michael Berkowski Avatar answered Oct 05 '22 23:10

Michael Berkowski