MySQL Tutorial character join function Concat usage
There are two Concat_ws (), concat () functions in MySQL character or field content join functions, let's look at their simple examples.
Concat (STR1,STR2,...)
Returns a string resulting from a connection parameter. If any of the arguments are null, the return value is null.
Mysql> Select Concat (' My station ', ' yes ', ' www.111cn.net ');
-> ' My station is Www.111cn.net '
It's a simple example, and we'll follow the database tutorial
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;
Inserting data
INSERT INTO ' test ' (' id ', ' C ', ' B ') values
(1, ' Fdsa ', ' FDSA '),
(2, ' FDA ', ' FDA '),
(5, ' vvvv ', ' fdsadddd ');
Instance
Select Concat (b, ' www.111cn.net ')
From ' Test '
where 1
Limit 0, 30
Results
Concat (b, ' www.111cn.net ')
Fdsawww.111cn.net
Fdawww.111cn.net
Fdsaddddwww.111cn.net
Concat_ws (SEPARATOR,STR1,STR2,...) functions, they suddenly all null, but do not remove spaces