gpt4 book ai didi

mysql - 如何在mysql concat中添加新行?

转载 作者:可可西里 更新时间:2023-11-01 07:01:16 25 4
gpt4 key购买 nike

这里我附上了我的查询。我想逐行显示地址。

   SELECT 
tp.acct_name,
tp.acct_no,
tp.acct_type,
tp.sub_type,
tp.eci_acct_no AS bs_ship_fwd_no,
tp.ecifwno AS bs_cons_no,
tp.ssline_number,
sc.code AS sales_person,
tp.disabled,
CONCAT(IF(ca.address1 IS NULL OR ca.address1 = '',
' ',
ca.address1),
', ',
IF(ca.city1 IS NULL OR ca.city1 = '',
' ',
CONCAT('City:', ca.city1)),
' ',
IF(ca.state IS NULL OR ca.state = '',
' ',
CONCAT('State:', ca.state)),
' ',
IF(cy.codedesc IS NULL OR cy.codedesc = '',
' ',
CONCAT('Country:', cy.codedesc)),
' ',
IF(ca.zip IS NULL OR ca.zip = '',
' ',
CONCAT('Zip:', ca.zip)),
' ',
IF(ca.phone IS NULL OR ca.phone = '',
' ',
CONCAT('PH#:', ca.phone))) AS address,
ca.city1 AS city,
ca.state,
cy.codedesc AS country,
ca.zip,
ca.contact_name,
ca.phone,
ca.fax,
ca.email1,
gi.poa,
gi.fw_fmc_no,
CONCAT(cr.codedesc, '-', cr.id) AS credit_status,
ar.credit_limit,
tp.forward_account
FROM
(SELECT
acct_name,
acct_no,
acct_type,
sub_type,
eci_acct_no,
ecifwno,
ssline_number,
disabled,
forward_account
FROM
trading_partner
WHERE
(acct_no LIKE '080STU0001%' OR acct_name LIKE '080STU0001%' OR search_acct_name LIKE '080STU0001%') AND (acct_type LIKE '%S%' OR (acct_type LIKE '%V%' AND sub_type = 'Forwarder') OR acct_type LIKE '%O%' OR acct_type = 'C')
ORDER BY acct_no
LIMIT 50) AS tp
JOIN
cust_address ca ON (tp.acct_no = ca.acct_no AND ca.prime = 'on')
LEFT JOIN
genericcode_dup cy ON ca.country = cy.id
LEFT JOIN
cust_general_info gi ON tp.acct_no = gi.acct_no
LEFT JOIN
genericcode_dup sc ON gi.sales_code = sc.id
LEFT JOIN
cust_accounting ar ON tp.acct_no = ar.acct_no
LEFT JOIN
genericcode_dup cr ON ar.credit_status = cr.id
GROUP BY tp.acct_no

我需要以下格式的输出。请帮忙

1771 EAST 9TH AVENUE,
CITY:AMPA,STATE:FL,COUNTRY:UNITED STATES,
ZIP:33605

提前致谢...

最佳答案

您可以使用 CHAR(13) 来做到这一点。
例如PRINT '文本 1' + CHAR(13) + '文本 2'

输出

Text 1
Text 2

关于mysql - 如何在mysql concat中添加新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37878652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com