如何在MySQL中将回车符附加到值? [英] How do you append a carriage return to a value in MySQL?

查看:51
本文介绍了如何在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

推荐答案

如果您想要换行,那么您正在寻找的是\n换行符,而不是回车符.

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() 将所有后续参数与第一个论点.因此,您可以通过以下方式添加多行:

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

这篇关于如何在MySQL中将回车符附加到值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆