How to get distinct values from a column with all its corresponding values in another column
Posted
by
Vishnu
on Stack Overflow
See other posts from Stack Overflow
or by Vishnu
Published on 2013-06-27T15:51:43Z
Indexed on
2013/06/27
16:21 UTC
Read the original article
Hit count: 290
I know the question is bit confusing. Please read below.
I have a table
table_categories (id INT(11), cname VARCHAR(25),survey_id INT(11))
I want to retrieve the values for the column cname without duplication, that is distinct values but with all the values in the other column.
id cname survey_id
-- -------- ---------
1 Trader 2
2 Beginner 2
25 Human 1
26 Human 2
From the above example I want to retrieve distinct cnames with all the values of the survey_id. I don't want to use any programming language. Is there any way by using a single query. Please give me a solution in MySQL.
© Stack Overflow or respective owner