SQL > SQL String Functions > Concatenate

The Concatenate function combines multiple character strings together. Each database provides its own way(s) to do this:

  • MySQL: CONCAT( )
  • Oracle: CONCAT( ), ||
  • SQL Server: +
SQL string concatenation joins column values and literal strings into a single result — the syntax differs by database: CONCAT() for MySQL/Oracle, || for Oracle/PostgreSQL, and + for SQL Server.

Syntax

The syntax for CONCAT( ) is as follows:

CONCAT (str1, str2, str3, ...)

The above syntax concatenates str1, str2, str3, and any other strings together. Each str can be a column name, or it can be a literal character string (meaning a sequence of characters enclosed by two single quotes), or just white space.

Please note the Oracle CONCAT( ) function only allows two arguments -- only two strings can be put together at a time using this function. However, it is possible to concatenate more than two strings at a time in Oracle using '||'.

The syntax for using '||' to concatenate is as follows:

str1 || str2 || str3 ...

The syntax for using '+' to concatenate is as follows:

str1 + str2 + str3 ...

Examples

We use the following table for our examples.

Table Geography

 Region_Name  Store_Name 
 East  Boston 
 East  New York 
 West  Los Angeles 
 West  San Diego 

Example 1: Use CONCAT function to concatenate

MySQL/Oracle:

SELECT CONCAT(Region_Name, Store_Name) FROM Geography 
WHERE Store_Name = 'Boston';

Result:

'EastBoston'

Example 2: Use '||' to concatenate

Oracle:

SELECT Region_Name || ' ' || Store_Name FROM Geography
WHERE Store_Name = 'Boston';

Result:

'East Boston'

Example 3: Use '+' to concatenate

SQL Server:

SELECT Region_Name + ' ' + Store_Name FROM Geography
WHERE Store_Name = 'Boston';

Result:

'East Boston'

Frequently Asked Questions

How do I concatenate strings in SQL?
The method depends on your database: use CONCAT(str1, str2, ...) in MySQL/Oracle, the || operator in Oracle or PostgreSQL, or the + operator in SQL Server.
Why does Oracle CONCAT() only accept two arguments?
Oracle's CONCAT() is limited to two arguments by design. To concatenate three or more strings in Oracle, use the || pipe operator: str1 || str2 || str3.
Can I mix column values and literal strings in concatenation?
Yes. Column names and string literals (enclosed in single quotes) can be combined freely. For example: CONCAT(First_Name, ' ', Last_Name) adds a space between the two columns.
What happens when I concatenate a NULL value?
In most databases, concatenating any string with NULL returns NULL. Wrap columns in COALESCE or ISNULL to substitute an empty string for NULLs before concatenating.

Next: SQL SUBSTRING

This page was last updated on March 19, 2026.




Copyright © 2026   1keydata.com   All Rights Reserved     Privacy Policy     About   Contact