Home > Database > Mysql Tutorial > body text

MySQL concat函数的使用

WBOY
Release: 2016-06-07 15:33:57
Original
1392 people have browsed it

MySQL concat函数是MySQL数据库中众多的函数之一,下文将对MySQL concat函数的语法和使用进行说明,供您参考和学习。 MySQL concat函数使用方法: CONCAT(str1,str2,…) 返回结果为连接参数产生的字符串。如有任何一个参数为NULL ,则返回为 NULL。 注意:

MySQL concat函数是MySQL数据库中众多的函数之一,下文将对MySQL concat函数的语法和使用进行说明,供您参考和学习。 

MySQL concat函数使用方法: 
CONCAT(str1,str2,…) 

返回结果为连接参数产生的字符串。如有任何一个参数为NULL ,则返回值为 NULL。 

注意: 
如果所有参数均为非二进制字符串,则结果为非二进制字符串。 
如果自变量中含有任一二进制字符串,则结果为一个二进制字符串。 
一个数字参数被转化为与之相等的二进制字符串格式;若要避免这种情况,可使用显式类型 cast, 例如: 
SELECT CONCAT(CAST(int_col AS CHAR), char_col) 

MySQL concat函数可以连接一个或者多个字符串,如 


mysql> select concat('10');  
+--------------+  
| concat('10') |  
+--------------+  
| 10   |  
+--------------+  
1 row in set (0.00 sec)  
 
mysql> select concat('11','22','33');  
+------------------------+  
| concat('11','22','33') |  
+------------------------+  
| 112233 |  
+------------------------+  
1 row in set (0.00 sec) 


MySQL的concat函数在连接字符串的时候,只要其中一个是NULL,那么将返回NULL 


mysql> select concat('11','22',null);  
+------------------------+  
| concat('11','22',null) |  
+------------------------+  
| NULL   |  
+------------------------+  
1 row in set (0.00 sec)  


参考来源: http://www.lai18.com/content/315803.html



Related labels:
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!