Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql Sql-functions MySQL Append Column

Related Tutorials


 
 

Share on Google+Share on Google+

MySQL Append Column

Advertisement
Appending columns values can be performed using CONCAT() function. By this function, values of columns can be concatenated and made them a single value.

MySQL Append Column

     

This example illustrates how to append two column values of a table.

Appending columns values can be performed using CONCAT() function. By this function, values of columns can be concatenated and made them a single value. In this example, we are concatenating  the value of "studentid", "sectionid", "courseid", "time" columns for each row of the "mca" table.

Table: "mca"

Table

+-----------+-----------+----------+----------------------------------+
| studentid | sectionid | courseid | time                             |
+-----------+-----------+----------+----------------------------------+
| 3         | 3         | 3        | Mon 14:30-16:00                  |
| 2         | 2         | 5        | Mon 11:30-12:00, Thu 09:00-11:00 |
| 1         | 1         | 6        | Mon 09:30-11:00                  |
+-----------+-----------+----------+----------------------------------+

Query to concatenate column values:

Query

select studentid, CONCAT(studentid, sectionid, courseid, time) FROM mca;

Output

+-----------+----------------------------------------------+
| studentid | CONCAT(studentid, sectionid, courseid, time) |
+-----------+----------------------------------------------+
| 3         | 333Mon 14:30-16:00                           |
| 2         | 225Mon 11:30-12:00, Thu 09:00-11:00          |
| 1         | 116Mon 09:30-11:00                           |
+-----------+----------------------------------------------+
Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 10, 2006

Related Tutorials

Discuss: MySQL Append Column  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com