-1

after doing this request i got the tab like this

Jumanji 2019    Action  Jan de  Bont
Jumanji 2019    Action  Jake    Kasdan
Jumanji 2019    Action  Dwayne  Johnson
Jumanji 2019    Comedie Jan de  Bont
Jumanji 2019    Comedie Jake    Kasdan
Jumanji 2019    Comedie Dwayne  Johnson
Speed 2 1997    Action  Sandra  Bullock
Speed 2 1997    Action  Jason   Patric

How i can join the third comumn like

Jumanji 2019    Action,Comedie  Jan de  Bont
Jumanji 2019    Action,Comedie  Jake    Kasdan
Jumanji 2019    Action,Comedie  Dwayne  Johnson
Speed 2 1997    Action          Sandra  Bullock
Speed 2 1997    Action          Jason   Patric

here is my query:

SELECT DISTINCT MEDIA.media_Titre, MEDIA.media_AnneeSortie,
       GENRE.genre_Nom,
       PERSONNE.personne_Nom, PERSONNE.personne_Prenom
FROM MEDIA, MEDIA_GENRE, METIER, ROLE, GENRE, PERSONNE 
WHERE MEDIA.typeMedia_Id=1 AND
      (MEDIA_GENRE.media_Id = MEDIA.media_Id AND 
       MEDIA_GENRE.genre_Id = GENRE.genre_Id
      ) AND
      (ROLE.artiste_Id = PERSONNE.personne_Id AND
       ROLE.media_Id = MEDIA.media_Id
      )
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Duy
  • 1
  • 2
  • I see a query with lots of tables referenced and no `JOIN`. Did you forget something? – Gordon Linoff Dec 07 '19 at 15:14
  • Its my question , there is alot of tables , really dont know how to join them – Duy Dec 07 '19 at 15:18
  • 1
    . . They are *your* tables. If you don't know how to `JOIN` them, how do think anyone else would know? – Gordon Linoff Dec 07 '19 at 15:19
  • i'm just learning sql , i think there is'nt stupid question , i really dont know that i can't ask the question like this – Duy Dec 07 '19 at 15:23
  • 1
    Why is the `METIER` table is included if you're not doing anything with it? – Alon Eitan Dec 07 '19 at 15:23
  • Thanks, i just see that , will remove it – Duy Dec 07 '19 at 15:27
  • Does this answer your question? [How to concatenate text from multiple rows into a single text string in SQL server?](https://stackoverflow.com/questions/194852/how-to-concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql-serv) – Shivam Puri Dec 07 '19 at 15:35

1 Answers1

0

After some days of learning more about SQL i found the way how i can join 2 row with same id

    select media.`media_Id`, media.`media_Titre`, type_media.`typeMedia_Nom`, concat_ws(",", GROUP_CONCAT(genre.`genre_Nom`)) as "genre", saga.`saga_Nom`, media.`livre_ISBN`, media.`media_AnneeSortie`
from  media
LEFT JOIN type_media on media.`typeMedia_Id` = type_media.`typeMedia_Id`
LEFT JOIN media_genre on media.`media_Id` = media_genre.`media_Id`
LEFT JOIN genre on genre.`genre_Id` = media_genre.`genre_Id`
LEFT JOIN saga on saga.`saga_Id`= media.`saga_Id`
where type_media.`typeMedia_Id` = 1
group by `media_Id`
Duy
  • 1
  • 2