gpt4 book ai didi

mysql - 如何在列中显示空白结果的某些文本。数据库

转载 作者:行者123 更新时间:2023-11-29 04:38:20 24 4
gpt4 key购买 nike

我需要为没有提供第二个地址的任何客户显示“未提供”字样。如果仅向 address2 列提供返回为空白的那些词,我将使用什么?

/* Create a customer list that shows the customer name, address, second address (if the customer does not list a second address, print out "none provided") 
and postal code. */

SELECT CONCAT(first_name," ",last_name) AS Name,
CONCAT(address.address,",",address.address2,",",postal_code) AS Customer_info
FROM customer
INNER JOIN address
ON customer.address_id = address.address_id;

最佳答案

使用IF()函数

CONCAT(address.address, ',', IF(address.address2 != '', address.address2, 'None provided'), ",", postal_code) AS Customer_info

关于mysql - 如何在列中显示空白结果的某些文本。数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35807101/

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