0

How to return multi- value columns in sql which is group by another column. I have a table that contain question_id and competency_id.what i want is to return all the question_id as a single column based on competency id.

 c_id = [1,2,1,2,3,1];
q_id=[20,21,23,26,24,25];

what i want

expected = [{c_id:1,q_id:[20,23,25]},{c_id:2,q_id:[21,26]},{c_id:3,q_id:[21,26]}];

what i tried

select c_id, q_id from table group by c_id;
Jeroen van Langen
  • 21,446
  • 3
  • 42
  • 57
Shubham Kumar
  • 2,171
  • 1
  • 13
  • 22
  • Possible duplicate of [Can I concatenate multiple MySQL rows into one field?](https://stackoverflow.com/questions/276927/can-i-concatenate-multiple-mysql-rows-into-one-field) – Jeroen van Langen Jul 05 '18 at 08:07
  • no its not the case of concatenation as i want to group my table according to c_id and list all the q_id belong to particular c_id – Shubham Kumar Jul 05 '18 at 08:20
  • Please include proper sample data, table definitions and expected output in your question – M Khalid Junaid Jul 05 '18 at 09:22

0 Answers0