GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • SQL
  • Projects
  • Interview Questions
  • Quiz
  • DBMS
  • PostgreSQL
  • Django
  • ReactJS
  • Vue.js
  • AngularJS
  • API
  • REST API
  • SQL3 min read
  • Data Types3 min read

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — Concatenation Operator in SQL - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • SQL
  • Projects
  • Interview Questions
  • Quiz
  • DBMS
  • PostgreSQL
  • Django
  • ReactJS
  • Vue.js
  • AngularJS
  • API
  • REST API

Concatenation Operator in SQL

Last Updated : 27 Oct, 2026

The SQL concatenation operator (||) is used to combine two or more strings, column values or literals into a single string. It helps create readable output by joining values or adding text to query results.

  • Combines values from multiple columns.
  • Adds text or numeric literals to query results.
  • Creates formatted output, such as full names or descriptive messages.

Syntax:

SELECT column_1 || column_2 AS new_column
FROM table_name;
  • column_1 and column_2 are the columns you want to concatenate.
  • AS new_column assigns a name to the concatenated result.

Example 1: Concatenating First Name & Last Name

We will create a demo SQL table named my_table containing employee details such as id, first_name, last_name and salary.

Query:

SELECT id, first_name, last_name,
first_name || last_name AS full_name,
salary
FROM my_table;

Output:

sql_Concatenation_Operator2

Explanation: This query combines the first_name and last_name columns using the concatenation operator to create a full_name column. The output displays each employee’s complete name alongside their salary.

Example 2: Concatenating Strings with a Literal

The my_table contains employee details, including id, first_name, last_name and salary. This query uses a string literal to combine an employee's name with their salary information.

Query:

SELECT id, first_name, last_name, salary,
first_name || ' has salary ' || salary AS new
FROM my_table;

Output:

sql_Concatenation_Operator1

Explanation: This query uses the concatenation operator (||) to combine the first_name and salary columns with the string literal ' has salary '. The result displays the employee's name along with their salary, such as James has salary 45000.

Example 3: Using a Number Literal in Concatenation

The my_table contains employee details. This query uses a number literal and a string literal with column values to create a combined string using the concatenation operator.

Query:

SELECT id, first_name, last_name, salary,
first_name || 100 || ' has id ' || id AS new
FROM my_table;

Output:

sql_Concatenation_Operator3

Explanation: This query concatenates a numeric literal (100) and a character literal (' has id ') with the first_name and id columns. The output provides a readable format that shows each employee's ID along with a custom message.

Comment

Explore

    Basics
    • SQL3 min read
    • Data Types3 min read
    • Operators4 min read
    • Commands5 min read
    • Database Operations2 min read
    • CREATE TABLE2 min read
    Queries & Operations
    • SELECT Query2 min read
    • INSERT INTO3 min read
    • UPDATE2 min read
    • DELETE2 min read
    • WHERE2 min read
    • Aliases2 min read
    Joins & Functions
    • Joins3 min read
    • CROSS JOIN1 min read
    • Date Functions2 min read
    • String functions4 min read
    Data Constraints & Aggregate Functions
    • NOT NULL Constraint3 min read
    • PRIMARY KEY3 min read
    • Count()4 min read
    • SUM()2 min read
    • MAX()3 min read
    • AVG()2 min read
    Advanced SQL Topics
    • Subquery4 min read
    • Window Functions4 min read
    • Stored Procedures3 min read
    • Triggers4 min read
    • Performance Tuning4 min read
    • TRANSACTIONS4 min read
    Database Design & Security
    • ER Model9 min read
    • Normalization2 min read
    • Keys in Relational Model7 min read
    • SQL Injection10 min read
    • Data Encryption3 min read
    • SQL Backup4 min read
    • ORM in DBMS5 min read
    Courses
    • Placement 360 Course2 min read
    • Data Science 360 Course2 min read
    • MERN Full Stack Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.