We can use the output of CONCAT() function which is applied to the column/s of a MySQL with the column/s of another MySQL table. It can be done with the help of MySQL join.
Example
For example, we have two table ‘Student’, having the details like id, Name, Last_name, Address and Subjects of the students, and ‘Remarks’, having the id and comments about the students. Now, the following query can combine CONCAT() function with another table column −
mysql> Select * from remarks; +------+-------------+ | ID | Comment | +------+-------------+ | 1 | Good | | 2 | Excellent | | 15 | Average | | 20 | Good | | 21 | Outstanding | +------+-------------+ 5 rows in set (0.00 sec) mysql> Select CONCAT(Name,' ' ,Last_Name ), Comment from student s, remarks r -> Where s.id = r.id; +------------------------------+-------------+ | CONCAT(Name,' ' ,Last_Name ) | Comment | +------------------------------+-------------+ | Gaurav Kumar | Good | | Aarav Sharma | Excellent | | Harshit Kumar | Average | | Gaurav Rathore | Good | | Yashraj Singh | Outstanding | +------------------------------+-------------+ 5 rows in set (0.00 sec)
Both the tables are joined on the basis of common ‘id’ of the students in both the tables.