Anonymous
Anonymous

Reputation: 1094

How to get mysql data from two rows and show them in single row by joining comma separated values?

Here I am retrieving user id in Mysql from two rows based onid_no so it will retrieve two separate rows but after that I Want that result should come in single row with comma separated.

query to get records:

SELECT uid FROM `users` WHERE id_no='f5e3fe73a8';

output:

but expected output uid=2,1 so how to do this using mysql query?

Upvotes: 2

Views: 52

Answers (1)

Jens
Jens

Reputation: 69495

use group_concat

SELECT group_concat(uid) FROM `users` WHERE id_no='f5e3fe73a8' Group by id_no

For more informations see the official documentation

Upvotes: 3

Related Questions