Home Sql Sql-functions MySql Append Codes
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

MySql Append Codes

Advertisement
We use CONCAT() function to append the values of two column. In this example, we are concatenating the value of "fname" column and the value of "lname" column for each row having value 'Programmer' in the 'designation' column of the "user" table.

MySql Append Codes

     

This example illustrates how to append the column values.

We use CONCAT() function to append the values of two column. In this example, we are concatenating  the value of "fname" column and the value of "lname" column for each row having value 'Programmer' in the 'designation' column of the "user" table.

Table "user":

Query

 

select * from user;

 

Output

 

+---------+---------+-------------------------------+
| fname   | lname   | designation                   |
+---------+---------+-------------------------------+
| sandeep | suman   | Programmer                    |
| suman   | saurabh | Sr. Graphics Designer         |
| saurabh | ranjan  | Content Writer                |
| ravi    | kant    | Software Developer            |
| deepak  | kumar   | IT Manager                    |
| noor    | ali     | Content Writer                |
| vikash  | kumar   | Content Writer                |
| vineet  | bansal  | Programmer                    |
+---------+---------+-------------------------------+

Query to concatenate fname and lname values:

Query

 

 SELECT CONCAT(fname, " ", lname)
 from user where designation = 'Programmer';
Output

 

+---------------------------+
| CONCAT(fname, " ", lname) |
+---------------------------+
| sandeep suman             |
| vineet bansal             |
+---------------------------+

 

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 6, 2010

Related Tutorials

Ask Questions?    Discuss: MySql Append Codes  

Post your Comment


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