Home > Database > Mysql Tutorial > body text

mysql 字符连接函数 CONCAT用法

WBOY
Release: 2016-06-07 17:45:56
Original
1417 people have browsed it

在mysql字符或字段内容连接函数有两个分别是CONCAT_WS(),CONCAT()函数了,下面看看他们简单的实例吧。

在mysql字符或字段内容连接函数有两个分别是CONCAT_WS(),CONCAT()函数了,下面看看他们简单的实例吧。

字符连接函数 concat用法

在mysql字符或字段内容连接函数有两个分别是concat_ws(),concat()函数了,下面看看他们简单的实例吧。


concat(str1,str2,...)

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

mysql> select concat('我的站', '是', 'www.111cn.net');

-> '我的站是

上面是个简单的实例,下面们我们根据来操作

数据库结构
create table if not exists `test` (
  `id` int(4) not null auto_increment,
  `c` text,
  `b` text,
  primary key  (`id`)
) engine=myisam  default charset=gb2312 auto_increment=7 ;

插入数据
insert into `test` (`id`, `c`, `b`) values
(1, 'fdsa', 'fdsa'),
(2, 'fda', 'fda'),
(5, 'vvvv', 'fdsadddd');


实例

select concat( b, 'www.111cn.net' )
from `test`
where 1
limit 0 , 30

结果

concat( b, 'www.111cn.net' ) 
fdsawww.111cn.net
fdawww.111cn.net
fdsaddddwww.111cn.net

concat_ws(separator,str1,str2,...) 函数,他们突然所有的null,但不删除空格

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!