Structure data group



  • I know it's not a difficult task, but I don't see my solution. I've been in the documentation, and there's plenty else.

    What's that?

    SELECT lawyer.lawyer_full_name,group_concat(client.client_full_name) 
      FROM client 
      JOIN cases  ON (client.client_id=cases.client_id) 
      JOIN lawyer ON (lawyer.lawyer_id=cases.lawyer_id) 
     GROUP BY lawyer.lawyer_full_name
    

    Turns out:

    Группа1Имя1 - Группа2Имя1,Группа2Имя2,Группа2Имя2
    Группа1Имя2 - Группа2Имя2
    

    It's got to be:

    Группа1Имя1 - Группа2Имя1,Группа2Имя2
    Группа1Имя2 - Группа2Имя2
    

    Sold the option GROUP BY lawyer.lawyer_full_name,client.client_full_name, but then he puts all the data in the pole. Would you mind?

    Thank you for your attention!



  • Use the key word. distinct group_concat for the suppression of duplicates

    SELECT lawyer.lawyer_full_name, group_concat(distinct client.client_full_name) 
      FROM client 
      JOIN cases  ON (client.client_id=cases.client_id) 
      JOIN lawyer ON (lawyer.lawyer_id=cases.lawyer_id)
     GROUP BY lawyer.lawyer_full_name
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2