Home >Database >Mysql Tutorial >What will MySQL return if we use NULL as parameter, one of the parameters, and delimiter in CONCAT_WS() function?

What will MySQL return if we use NULL as parameter, one of the parameters, and delimiter in CONCAT_WS() function?

WBOY
WBOYforward
2023-08-24 08:01:14965browse

如果我们在 CONCAT_WS() 函数中使用 NULL 作为参数、参数之一和分隔符,MySQL 将返回什么?

NULL as two parameters

If we use NULL as two parameters in CONCAT_WS() function, MySQL will return blank output.

Example

mysql> Select CONCAT_WS('',NULL,NULL);
+-------------------------+
| CONCAT_WS('',NULL,NULL) |
+-------------------------+
|                         |
+-------------------------+
1 row in set (0.00 sec)

NULL as one of the parameters

If we use NULL as one of the parameters in the CONCAT_WS() function, MySQL will return the value of the other parameter as output .

Example

mysql> Select CONCAT_WS('',NULL,'Delhi');
+----------------------------+
| CONCAT_WS('',NULL,'Delhi') |
+----------------------------+
| Delhi                      |
+----------------------------+
1 row in set (0.00 sec)

mysql> Select CONCAT_WS('','Ram',NULL);
+--------------------------+
| CONCAT_WS('','Ram',NULL) |
+--------------------------+
| Ram                      |
+--------------------------+
1 row in set (0.00 sec)

NULL at delimiter

If we use NULL at delimiter in CONCAT_WS() function, MySQL will return NULL as output.

Example

mysql> Select CONCAT_WS(NULL, 'NEW','DELHI');
+--------------------------------+
| CONCAT_WS(NULL, 'NEW','DELHI') |
+--------------------------------+
| NULL                           |
+--------------------------------+
1 row in set (0.00 sec)

The above is the detailed content of What will MySQL return if we use NULL as parameter, one of the parameters, and delimiter in CONCAT_WS() function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete