Himanshu Upadhyay
Himanshu Upadhyay

Reputation: 743

How to concatenate multiple rows into a single text string without using loop?

Suppose i have a table with the following data:

ClientID    ClientName
3           saurabh Malhotra
4           patel Mon
6           Sajith raju
7           Vipin parmar
8           Monoj trivedi

We need to concatenate the ClientName column like the following:

saurabh Malhotra, patelMon, Sajith raju, Vipin parmar, Monoj trivedi

Upvotes: 0

Views: 1071

Answers (2)

Vishnu
Vishnu

Reputation: 375

Try This :)

SELECT GROUP_CONCAT(ClientName) FROM Your_table_name

MySQL : Multiple row as comma separated single row

Upvotes: 1

Mukesh Kalgude
Mukesh Kalgude

Reputation: 4844

Try this query

select 
     group_concat(ClientName  separator ',') as ClientName 
from (select 1 as tempcol,
           ClientName 
     from tablename)tbl
group by tempcol

Upvotes: 1

Related Questions