How to get distinct values from a column with all its corresponding values in another column
- by Vishnu
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.