Name

Concatenation Operators

Synopsis

When it is necessary to combine the data of multiple columns into a single column in SELECT result set, the concatenation symbol supported by the DBMS may be used to achieve this result.

Vendor

Command

SQL Server

Supported, with variations

MySQL

Supported, with variations

Oracle

Supported

PostgreSQL

Supported

Example and Description

SELECT lname || ', ' || fname FROM customers WHERE cust_id = 41;

The ANSI standard is a double-pipe mark ( || ), as shown in the previous code example, and is supported by Oracle and PostgreSQL.

Microsoft SQL Server uses a plus sign ( + ) as its concatenation symbol.

MySQL uses the CONCAT(string1, numeric1, string2, numeric2 [,...n]) function to accomplish concatenation.

Get SQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.