【发布时间】:2021-05-13 13:54:57
【问题描述】:
我想把属于同一个id的输出拼接起来,所以我用了下面这个函数,但是我也想用自定义文本替换空值,怎么做才对呢?
GROUP_CONCAT(IFNULL(ps_state.name, 'No-State') SEPARATOR ', ')
所有代码(如果需要):
SELECT DISTINCT ps_customer.id_customer AS CustomersId, ps_customer.email AS CustomersName, GROUP_CONCAT(IFNULL(ps_state.name, 'No') SEPARATOR ', ') AS StatesName,
GROUP_CONCAT(ps_country_lang.name SEPARATOR ', ') AS CountryName
FROM ps_customer
INNER JOIN ps_address ON ps_customer.id_customer=ps_address.id_customer
LEFT JOIN ps_state ON ps_state.id_state=ps_address.id_state
INNER JOIN ps_country_lang ON ps_country_lang.id_country=ps_address.id_country
WHERE ps_country_lang.id_lang=1
GROUP BY ps_customer.id_customer, ps_state.name
【问题讨论】:
标签: sql null concatenation