Monthly Archives: January 2013

MySQL CONCAT function (merge columns together)

This doesn’t happen often that it’s necessary to do on the database side but I feel like this would save a step during PHP development and let MySQL do some work.

In MySQL, the function CONCAT() – returns a string where arguments (columns/string in database) are joined together to make one string. You can read more on the description of this function here.

Let’s say you have two columns, FIRST_NAME and LAST_NAME. To join these two columns together in MySQL you would use the following SQL statement:

This will return a result set with first name and last name joined together so you don’t have to do this using PHP processing.