Concatenate Multiple Columns in MySQL — Phpflow.com

in this tutorial, We ll concatenate two or multiple columns in MySQL.We will select the values and concat multiple columns using MySQL inbuilt method.

It can also achieve same thing using programmatically. You need to select columns fields value separately from MySQL Table and store their values in the single variable after concat their values.

Case 1: I am assuming, We have firstname, lastname column within our DataBase Table.Concatenate firstname, lastname columns values in a single string form.

There are two functions for doing this -

Above function work for concate multiple columns :

CONCAT

This function is used to concatenate multiple columns or strings into a single one. The method arguments are separated by a comma.

Syntax -

MySQL Query to Concatenate table Columns

CONCAT_WS

The CONCAT_WS() function is used add multiple string values and makes them a single string value.The main difference between CONCAT() and CONCAT_WS() is that we can define separator. It also let you define separator ( " ", ", ", " - ", etc.).

Syntax -

Example concatenate Using CONCAT_WS()

Originally published at https://www.phpflow.com on January 1, 2021.

--

--

--

Hey, I am Parvez Alam. A software developer since 2009. I am a programming addict. I love learning and sharing knowledge. https://www.phpflow.com/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Generator the client to sql database on Golang

Who’s afraid of serverless computing?

Writing a Custom OAuth2 Grant Type in WSO2 Identity Server

Pass By Reference vs. Pass By Value

Easily Parse Nested JSON in Go

How to create your own Rust Server

Auto scaling and Load Balancing using AWS

#XfEffects: Xamarin.Forms Effect to change the Tint color of ImageButton’s image — (new series)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Parvez Alam

Parvez Alam

Hey, I am Parvez Alam. A software developer since 2009. I am a programming addict. I love learning and sharing knowledge. https://www.phpflow.com/

More from Medium

How to Configure Nutanix VMware Cluster Field Installation — Part 5 — ICT Fella

Two ways to reference version numbers in your project’s build.gradle file

Using batch file to get wifi SSID

SuperPunksNFT & DogeElonNFT