Home > Back-end >  MySQL: Get DISTINCT values of repeated values and GROUP CONCAT of non-repeating values which are par
MySQL: Get DISTINCT values of repeated values and GROUP CONCAT of non-repeating values which are par

Time:03-12

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.

CodePudding user response:

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

CodePudding user response:

SELECT id, show_id, show_name, session_id, GROUP_CONCAT(day) FROM table GROUP BY show_id, show_name, session_id;

  • Related