How to Concatenate Strings in SQL
See SQL: Tips and Tricks for similar articles.
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 EmployeesString Concatenation in Oracle
In Oracle, concatenation is done with the || (two pipes) operator.
SELECT FirstName || ' ' || LastName AS FullName
FROM EmployeesOracle also supports the CONCAT() function:
SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM EmployeesString Concatenation in MySQL
In MySQL, concatenation is with the CONCAT() function.
SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM EmployeesString Concatenation in PostgreSQL
In PostgreSQL, like Oracle, concatenation is done with the || (two pipes) operator.
SELECT FirstName || ' ' || LastName AS FullName
FROM EmployeesPostgreSQL also supports the CONCAT() function:
SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM Employees