Add to Favorites

Mysql concat function

If you haven't used the concat() function in mysql you are missing out. It allows you to do selects and updates ( as well as other things ) using a concatenation of either columns, fields or both.

For example, you have a database table of users. This table has two columns one for first name and one for last name. You'd like to concat the fields together and return it as a single column full name. You can use a query like:

select concat(first_name,' ',last_name) as full_name from user

It is also useful in many other situations, as you will see during your programming excursions.


Be the first to leave a comment on this post.

Leave a comment

To leave a comment, please log in / sign up