How to Concatenate Strings in SQL

See SQL: Tips and Tricks for similar articles.
Looking to improve your SQL skills? Check out Webucator’s SQL classes.

SQL Server, Oracle, MySQL and PostgreSQL each have their own way of doing string concatenation.

String Concatenation in SQL Server

In SQL Server, concatenation is done with the + operator.

SELECT FirstName + ' ' + LastName AS FullName
FROM Employees

String Concatenation in Oracle

In Oracle, concatenation is done with the || (two pipes) operator.

SELECT FirstName || ' ' || LastName AS FullName
FROM Employees

Oracle also supports the CONCAT() function:

SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM Employees

String Concatenation in MySQL

In MySQL, concatenation is with the CONCAT() function.

SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM Employees

String Concatenation in PostgreSQL

In PostgreSQL, like Oracle, concatenation is done with the || (two pipes) operator.

SELECT FirstName || ' ' || LastName AS FullName
FROM Employees

PostgreSQL also supports the CONCAT() function:

SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM Employees

Related Articles

  1. Reset Root Password in MySQL on Windows
  2. How to Create an ER Diagram for a MySQL Database with Free Tools
  3. How to Round Up in SQL
  4. How to Concatenate Strings in SQL (this article)
  5. How to Select All Columns in a Row in SQL
  6. How to Check Multiple Conditions in SQL
  7. How Work with White Space and Semicolons in Simple SQL Selects
  8. How to Sort Records in SQL
  9. How to Write Subqueries (Simple and Correlated)