This article mainly introduces the use of concat function in MySQL tutorial, is the basic knowledge of Python introductory learning, need friends can refer to the
Use the MySQL CONCAT () function to concatenate two strings to form a single string. Try the following example:
?
1 2 3 4 5 6 7 |
mysql> SELECT CONCAT (' A ', ' SECOND '); +----------------------------+ | CONCAT (' A ', ' SECOND ') | +----------------------------+ | The SECOND | +----------------------------+ 1 row in Set (0.00 sec) |
Learn more about the CONCAT function, considering that the EMPLOYEE_TBL table has the following records:
?
1 2 3 4 5 6 7 8 9 10 11 12-13 |
Mysql> SELECT * from EMPLOYEE_TBL; +------+------+------------+--------------------+ | ID | name | Work_date | Daily_typing_pages | +------+------+------------+--------------------+ | 1 | John | 2007-01-24 | 250 | | 2 | Ram | 2007-05-27 | 220 | | 3 | Jack | 2007-05-06 | 170 | | 3 | Jack | 2007-04-06 | 100 | | 4 | Jill | 2007-04-06 | 220 | | 5 | Zara | 2007-06-06 | 300 | | 5 | Zara | 2007-02-06 | 350 | +------+------+------------+--------------------+ 7 rows in Set (0.00 sec) |
You can use the following command to link the name and ID in the previous table:
?
1 2 3 4 5 6 7 8 9 |
mysql> SELECT CONCAT (ID, name, work_date)-> from Employee_tbl; +-----------------------------+ | CONCAT (ID, name, work_date) | +-----------------------------+ | 1john2007-01-24 | | 2ram2007-05-27 | | 3jack2007-05-06 | | 3jack2007-04-06 | | 4jill2007-04-06 | | 5zara2007-06-06 | | 5zara2007-02-06 | +-----------------------------+ 7 rows in Set (0.00 sec) |