CONCAT (STR1,STR2,...)
Returns a string resulting from a connection parameter. If any of the arguments are null, the return value is null.
For example:
SELECT CONCAT (CAST (Int_col as CHAR), Char_col)
MySQL Query date and time:
The code is as follows |
Copy Code |
Mysql> Select Concat (Curdate (), ", Curtime ()); +------------------------------------+ | Concat (Curdate (), ", Curtime ()) | +------------------------------------+ | 2013-04-26 14:21:05 | +------------------------------------+ 1 row in Set (0.00 sec)
|
The MySQL concat function can connect one or more strings, such as
code is as follows |
copy code |
mysql> Select Concat (' Ten '); +--------------+ | concat (' 10 ') | +--------------+ | 10 | +--------------+ 1 row in Set (0.00 sec) &nb sp; mysql> Select concat (' One ', ', ', '); +------------------------+ | concat (' One, ', ', ') | +------------------------+ | 112233 | +------------------------+ & nbsp; 1 row in Set (0.00 sec) |
Concat_ws () represents CONCAT with Separator and is a special form of CONCAT (). The first parameter is the separator for the other arguments. The position of the separator is placed between the two strings to which you want to connect. The delimiter can be a string, or it can be another parameter. If the delimiter is null, the result is null. function ignores NULL values after any of the delimiter parameters.
The code is as follows |
Copy Code |
mysql> SELECT concat_ws (', ', ' ' name ', ' Second name ', ' last Name '); -> ' Name,second name,last name ' mysql> SELECT concat_ws (', ', ' ' name ', ' NULL ', ' last Name '); -> ' name,last name ' |
The MySQL Concat_ws () does not ignore any empty strings. (All NULL is ignored, however).