SQL CONCAT() Function
The SQL CONCAT() function is used to concatenate or joins strings from one or more string or expression.
The SQL CONCAT() function is supports or work with character expression and also many databases supports numeric based expressions.
It can be used in any valid SQL SELECT statement as well in SQL where clause.
Search Keys
- sql concat function
- sql concat
- concat
- concat sql
- concat sql server
- sql concatenate string
- sql server concatenate
- sql string concatenation
- select concat
- sql concatenate columns
- sql concatenate text
- sql query concatenate
SQL CONCAT() Syntax
The below syntax is used to concatenate strings from a given input string or expression.
For SQL SERVER / MYSQL
SELECT CONCAT(string1, string2, ..., stringN);
For ORACLE
SELECT CONCAT(string1, string2);
Note: The Oracle CONCAT() function will support only 2 string at once.
The below syntax is how to concatenate multiple strings in oracle:
SELECT CONCAT(CONCAT(string1, string2), string3);
For MS ACCESS
SELECT string1 & string2;
Note: The CONCAT() function will not support by ms access.
It uses "&" operator to concatenate a strings.
The below syntax is used to concatenate strings from a in a specific column value.
For SQL SERVER / MY SQL
SELECT CONCAT(column_name1, column_name2) FROM table_name;
For MS ACCESS
SELECT column_name1 & column_name2 & ...column_nameN) FROM table_name;
SQL CONCAT() Example - Using Expression Or Formula
The following SQL SELECT statement concatenate three strings as a single string.
SELECT CONCAT('Sql', ' ', 'Tutorial') AS 'Concatenated Strings';
The result of above query is:
Concatenated Strings |
Sql Tutorial |
SQL CONCAT() Function More Example
Input Value |
Result |
CONCAT('Hi!') |
Hi! |
CONCAT('Hi!', 'Hello') |
Hi!Hello |
CONCAT('Welcome ', 'To ', 'Simmanchith ', '.com') |
Welcome To Simmanchith.com |
CONCAT('Simmanchith', '.', 'com') |
Simmanchith.com |
CONCAT('James', ' ', 'Bond', ' ', '007') |
James Bond 007 |
Sample Database Table - Employee
ID |
FName |
LName |
Gender |
Age |
City |
State |
111 |
Suresh |
Babu |
Male |
32 |
Nasik |
MH |
222 |
Siva |
Kumar |
Male |
22 |
Chennai |
TN |
333 |
Bala |
Murugan |
Male |
33 |
Nasik |
MH |
444 |
Bala |
Karthik |
Male |
20 |
Madurai |
TN |
555 |
Haris |
Karthik |
Male |
25 |
Bangalore |
KN |
666 |
Varshini |
Kutty |
Female |
28 |
Madurai |
TN |
777 |
Azagu |
Murugan |
Male |
21 |
Madurai |
TN |
888 |
Azagu |
Varshith |
Female |
26 |
Bangalore |
KN |
SQL CONCAT() Example
The following SQL statement concatenate the "FName" and "LName" column from the "Employee" table and produce a new column called as "EmpName" to the result set:
For SQL SERVER / MySql
SELECT ID, CONCAT(FName, ' ', LName) As 'Emp Name',
City FROM Employee;
For MS Access
SELECT ID, FName & ' ' & LName As 'Emp Name',
City FROM Employee;
The result of above query is:
ID |
Emp Name |
City |
111 |
Suresh Babu |
Nasik |
222 |
Siva Kumar |
Chennai |
333 |
Bala Murugan |
Nasik |
444 |
Bala Karthik |
Madurai |
555 |
Haris Karthik |
Bangalore |
666 |
Varshini Kutty |
Madurai |
777 |
Azagu Murugan |
Madurai |
888 |
Azagu Varshith |
Bangalore |