

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we combine values of two or more columns of MySQL table and get that value in a single column?
For combining values of two or more columns, we can use MySQL CONCAT() function. In this case, the arguments of the CONCAT() functions would be the name of the columns. For example, suppose we have a table named ‘Student’ and we want the name and address of the student collectively in one column then the following query can be written −
mysql> Select Id, Name, Address, CONCAT(ID,', ',Name,', ', Address)AS 'ID, Name,Address' from Student; +------+---------+---------+--------------------+ | Id | Name | Address | ID, Name, Address | +------+---------+---------+--------------------+ | 1 | Gaurav | Delhi | 1, Gaurav, Delhi | | 2 | Aarav | Mumbai | 2, Aarav, Mumbai | | 15 | Harshit | Delhi | 15, Harshit, Delhi | | 20 | Gaurav | Jaipur | 20, Gaurav, Jaipur | +------+---------+---------+--------------------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- How can we combine the values of two or more columns of MySQL table?
- MySQL query to combine two columns in a single column?
- How can we fetch one or more columns as output from a MySQL table?
- How can we add values into the columns of a MySQL table?
- How we can get more information about columns of a table than the information we got by DESCRIBE, EXPLAIN and SHOW COLUMNS MySQL statements?
- How can we get a list of columns in an existing MySQL table?
- How can we get more details about columns of an existing table than return by MySQL SHOW COLUMNS statement?
- In MySQL, how can I combine two or more strings along with a separator?
- Get the highest score value from a single column and the greatest from two columns in MySQL
- Split float value in two columns of a MySQL table?
- How can we count a number of unique values in a column in MySQL table?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can we use LPAD() or RPAD() functions with the values in the column of a MySQL table?
- How to combine different columns of a table to yield a single column in query output in PostgreSQL?
- How can we extract a substring from the value of a column in MySQL table?
Advertisements