The CONCAT()
function is used to concatenate n number of arguments.
The illustration below shows how the CONCAT()
function works.
CONCAT(arg1, arg2, .... argn)
The CONCAT()
function takes in n number of arguments as a parameter.
The CONCAT()
function returns the single string
concatenating the arguments sent as parameter.
The example below shows how we can use the CONCAT()
function to concatenate the first and last names of the students.
Student ID | Student First Name | Student Last Name |
1 | David | Lew |
2 | Luiss | Kevin |
3 | Harvey | Dave |
4 | Lucy | Dan |
5 | Andrew | Wade |
select *, CONCAT(studentFirstName,' ',studentLastName) as studentFullNamefrom Students
This example explains some other implementations of the CONCAT()
function.
-- concat the numbersSELECT CONCAT(9,10,100);-- concat the number and stringSELECT CONCAT('Educative', 10);