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
Release: 2023-08-24 08:01:14
forward
979 people have browsed it

如果我们在 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)
Copy after login

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template