Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MySQL: Get DISTINCT values of repeated values and GROUP CONCAT of non-repeating values which are part of the same table

I have this table:
enter image description here
I want to get results something like this:
enter image description here

If you note,

  1. I require the id of the first record which matches the condition. For example, ID 6 & 8 are the first record of SH001 – S2 & SH002 – S1, respectively.
  2. Plus values in ‘day’ should be of proper sequence as shown & not like ‘Fri,Mon,Thu’.

I tried some queries but it was not giving me the intended results. So can anyone help me in the same.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

SELECT MIN(id), show_id, show_name, season_id, GROUP_CONCAT(day)
FROM table
GROUP BY 2,3,4
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading