There are two connection functions in the mysql character or field content: CONCAT_WS () and CONCAT (). Let's take a look at their simple examples.
Mysql tutorial concat usage
There are two connection functions in the mysql character or field content: concat_ws () and concat (). Let's take a look at their simple examples.
Concat (str1, str2 ,...)
Returns the string generated by the connection parameter. If any parameter is null, the return value is null.
Mysql> select concat ('My website', 'yes', 'www. bKjia. c0m ');
-> 'My site is www. bKjia. c0m'
The above is a simple example. We will operate it according to the database tutorial below.
Database Structure
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 data
Insert into 'test' ('id', 'C', 'B') values
(1, 'fdsa ', 'fdsa '),
(2, 'fda ', 'fda '),
(5, 'vvvv ', 'fdsadddd ');
Instance
Select concat (B, 'www. bKjia. c0m ')
From 'test'
Where 1
Limit 0, 30
Result
Concat (B, 'www. bKjia. c0m ')
Fdsawww. bKjia. c0m
Fdawww. bKjia. c0m
Fdsaddddwww. bKjia. c0m
Concat_ws (separator, str1, str2,...) function, they suddenly all null, but do not delete Spaces