Open links in new tab
    Upvotes419edited Dec 17, 2021 at 20:21

    MySQL is different from most DBMSs' use of + or || for concatenation. It uses the CONCAT function:

    SELECT CONCAT(first_name, ' ', last_name) AS Name FROM test.student

    There's also the CONCAT_WS (Concatenate With Separator) function, which is a special form of CONCAT():

    SELECT CONCAT_WS(' ', first_name, last_name) from test.student

    That said, if you want to treat || as a string concatenation operator (same as CONCAT()) rather than as a synonym for OR in MySQL, you can set the PIPES_AS_CONCAT SQL mode.

    Content under CC-BY-SA license
    Was this helpful?
  1. String concatenation in MySQL - Stack Overflow

    Feb 2, 2018 · That said, if you want to treat || as a string concatenation operator (same as CONCAT()) rather than as a synonym for OR in MySQL, …

  2. People also ask
  3. MySQL CONCAT () Function

    In this tutorial, you will learn how to use the MySQL CONCAT function to concatenate multiple strings into a single string.

  4. MySQL CONCAT () Function: Usage & Examples - DataCamp

    Learn how to effectively use the MySQL `CONCAT ()` function to merge strings, handle NULL values, and optimize data presentation in your SQL queries with practical examples.

  5. How to Concatenate Strings in MySQL? [2] …

    MySQL supports string concatenation with the CONCAT () and CONCAT_WS () functions. In this tutorial, we will go through examples on how to …

  6. Using CONCAT function in MySQL 8: A Practical Guide

    Jan 26, 2024 · In this guide, we will take an in-depth look at the CONCAT function, demonstrate its use with multiple examples, and learn how to leverage it in MySQL 8. The CONCAT function in …

  7. CONCAT function in MySQL - Syntax and Examples

    Aug 26, 2022 · In this article, we will explore how to use the MySQL CONCAT function to concatenate two or more strings, look at its syntax, and walk …

  8. Solved: How to Concatenate Multiple MySQL Rows into One

    Nov 1, 2024 · Learn how to concatenate multiple rows into a single field in MySQL using GROUP_CONCAT, IF statements, and other methods. Get practical examples and solutions for …

  9. MySQL CONCAT And GROUP_CONCAT Functions …

    Apr 1, 2025 · This tutorial explains how to use MySQL CONCAT with Select and GROUP_CONCAT functions with syntax and practical examples.

  10. MySQL String Concatenation: CONCAT & Pipe …

    Nov 1, 2025 · MySQL primarily uses the CONCAT function and the pipe operator (||) to perform string concatenation. This article will explain these …