Tutorial on using CONCAT functions in MySQL
This article describes how to use the CONCAT function in MySQL. It is the basic knowledge of getting started with Python. For more information, see
Use the MySQL CONCAT () function to connect two strings to form a single string. Try the following example:
?
| 1 2 3 4 5 6 7 |
Mysql> select concat ('first', 'second '); + ---------------------------- + | CONCAT ('first', 'second') | + ---------------------------- + | First second | + ---------------------------- + 1 row in set (0.00 sec) |
To learn more about the CONCAT function, consider 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 | 250 | | 2 | Ram | 220 | | 3 | Jack | 170 | | 3 | Jack | 100 | | 4 | Jill | 220 | | 5 | Zara | 300 | | 5 | Zara | 350 | + ------ + ------------ + -------------------- + 7 rows in set (0.00 sec) |
You can use the following command to link the name and ID in the preceding table:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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-06 6 | | 5Zara2007-06-06 | | 5Zara2007-02-06 | + ----------------------------- + 7 rows in set (0.00 sec) |