1.CONCAT () Stitching single-line string
Select concat (' + ', user_id) from table1;
Select Concat (' 11 ', ' 22 ', ' 33 ');
Results 112233
MySQL's concat function will return NULL if one is null when the string is concatenated.
Select Concat (' One ', ' n ', null);
Result NULL
2.group_cancat () stitching strings of all rows queried into a string to return
For example: I use Select Dictinct date from table1 to get the following table
200805
200806
200807
200808
200809
200810
200811
Now I need to stitch up this column of the resulting table into a string that
200805,200806,200807,200808,200809,200810,200811
Select Group_concat (dictinct date) from table1;
Select Group_concat(dictinct ' 001-', date) from table1; Stitching strings and returning different
Back to 001-200805,001-200806,001-200807,001-200808,001-200809,001-200810,001-200811
MySQL string concatenation function cancat () and Group_cancat ()