how to concat two columns in sql?

Today, We want to share with you how to concat two columns in sql.In this post we will show you mysql concat_ws, hear for how to concat two columns into one with the existing column name in mysql? we will give you demo and example for implement.In this post, we will learn about Laravel 6 CONCAT Multiple Columns with example with an example.

MySQL CONCAT() Function

SELECT CONCAT("SQL ", "Tutorial ", "is ", "fun!") AS ConcatenatedString;

Baisc Example 1:

SELECT CONCAT(c.FIRSTNAME, ',', c.LASTNAME) AS FIRSTNAME,
       c.*
FROM   `customer` c;

Add three columns into one “Address” column:

SELECT CONCAT(Address, " ", PostalCode, " ", City) AS Address
FROM Members;

Concatenate two columns in MySQL

select CONCAT(yourColumnName1, ' ',yourColumnName2) as anyVariableName from yourTableName;

create table bothcollumnjoinExample

mysql> create table bothcollumnjoinExample
   −> (
   −> MemberId int,
   −> MemberName varchar(200),
   −> MemberAge int
   −> );
Query OK, 0 rows affected (1.06 sec)

insert some records in the table

mysql> insert into bothcollumnjoinExample values(1,'Rohit',21);
Query OK, 1 row affected (0.18 sec)

mysql> insert into bothcollumnjoinExample values(2,'virat',24);
Query OK, 1 row affected (0.17 sec)

mysql> insert into bothcollumnjoinExample values(3,'Bhajiun',22);
Query OK, 1 row affected (0.13 sec)

mysql> insert into bothcollumnjoinExample values(4,'Jayshukhson',19);
Query OK, 1 row affected (0.17 sec)

Display all records

mysql> select *from bothcollumnjoinExample;

the CONCAT() function to concatenate two columns

mysql> select CONCAT(MemberName, ' ',MemberAge) as NameAndAgeColumn from bothcollumnjoinExample;

I hope you get an idea about mysql string concat operator.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment