如何在MYSQL结果中插入换行

时间:2019-01-22 15:06:23

标签: mysql

您如何做到这一点:

SELECT CONCAT(FIRST_NAME,' ' ,LAST_NAME, ADDRESS1, CITY,', ',STATE, ZIP) AS NAME

给出如下结果:

Joe Donuts
123 Main St
New York, NY 11111

我尝试添加'\ n'无效。

1 个答案:

答案 0 :(得分:0)

尝试将CONCAT_WS\n用作换行符:

SELECT
    CONCAT_WS('\n', CONCAT(FIRST_NAME, ' ', LAST_NAME),
              ADDRESS1,
              CONCAT(CITY, ', ', STATE, ' ', ZIP)) AS NAME
FROM yourTable;

enter image description here

Demo