-2

I have two columns (groupID, memberID) in table and I execute following mysql query

select `groupID` from `tbl_groupassign` where `memberID` = 'check1';

which prints column groupID but I want to show groupID in single row with each groupID separated by comma. For example I get following result by executing above query

groupID

group1

group2

but I want show it as group1, group2

0

1 Answer 1

7

Use GROUP_CONCAT

SELECT GROUP_CONCAT(`groupID` SEPARATOR ',') FROM `tbl_groupassign` WHERE `memberID` = 'check1' GROUP BY `memberID`;
Sign up to request clarification or add additional context in comments.

1 Comment

very fast reply. Thanks for the solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.