GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Concatenation Operator in SQL - GeeksforGeeks Concatenation Operator in SQLLast 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.
Syntax:
Example 1: Concatenating First Name & Last NameWe will create a demo SQL table named my_table containing employee details such as id, first_name, last_name and salary. Query:
Output: ![]() 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 LiteralThe 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:
Output: ![]() 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 ConcatenationThe 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, Output: ![]() 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 ExploreData Constraints & Aggregate Functions |
| 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. |