CONCAT()如果函数的任何参数为NULL ,它将返回NULL。这意味着如果我们将包含NULL值的列名作为CONCAT()函数的参数之一传递,则MySQL将返回NULL 。以下是“学生”表的示例进行说明。

示例

我们串联了两个字符串的值,并且在第5行第一处,该值为NULL,因此串联结果也为NULL。

mysql> Select Name, Address, CONCAT(Name,' Resident of ',Address)AS 'Detail of Student' from Student;  +---------+---------+---------------------------+ | Name    | Address | Detail of Student         | +---------+---------+---------------------------+ | Gaurav  | Delhi   | Gaurav Resident of Delhi  | | Aarav   | Mumbai  | Aarav Resident of Mumbai  | | Harshit | Delhi   | Harshit Resident of Delhi | | Gaurav  | Jaipur  | Gaurav Resident of Jaipur | | Yashraj | NULL    | NULL                      | +---------+---------+---------------------------+  5 rows in set (0.00 sec)