
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How MySQL CONCAT() function, applied to the column/s of a table, can be combined with the column/s of other tables?
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.
- Related Articles
- How can CONCAT() function be applied on columns of MySQL table?
- How can we apply BIT_LENGTH() function on the column/s of MySQL table?
- How can we modify column/s of MySQL table?
- What can another keyword be used instead of MODIFY to modify the column/s of MySQL table?
- How can we add day/s in the date stored in a column of MySQL table?
- How can we use MySQL EXPORT_SET() function with column of a table?
- How can I use MySQL INTERVAL() function with a column of a table?
- How can column data values of a table be compared using MySQL STRCMP() function?
- What is the use of DEFAULT constraint? How can it be applied to a column while creating a table?
- How MySQL aggregate functions can be combined with MySQL IF() function?
- How can we create a new MySQL table by selecting specific column/s from another existing table?
- How can CONCAT() function be used with MySQL WHERE clause?
- How wildcard characters can be used with MySQL CONCAT() function?
- MySQL CONCAT a specific column value with the corresponding record
- Which MySQL function can be used to append values of a column with single quotes?

Advertisements