MySQL

How to use the CONCAT MySql function to concatenate 2 table columns

Written by Ian Carnaghan · 20 sec read >

The CONCAT function can be used to concatenate two strings to form a single string or two columns to form a single column.

Say for Example you have a table users with columns name and surname and you would like to display both as one name you would use the CONCAT function to join the two fields as in the Example below

SELECT CONCAT(name," ",surname) AS fullname FROM users;

The above code will display something similar to Joe Soap should Joe be stored in the name column and Soap be stored in the surname column.

Last Updated On March 23, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. In my spare time I teach undergraduate classes in web development. Profile

Leave a Reply

avatar
  Subscribe  
Notify of