O'Reilly logo

SQL in a Nutshell by Kevin Kline

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required