where do I use left Join in this case? no msql

Asked

Viewed 57 times

-2

I need to put the left join in which case here you can tell me where the mistake is?

select a.nome_artista, count(*) as numero_musicas 
  from artista a, musica m 
 where m.id_artista = a.id_artista
 group by a.nome_artista
  • 1

    count(*) are you telling what? put the field, can’t tell * because there’s more than one table there

  • Ricardo, thanks I got here what I needed

1 answer

-3

Diego, understanding that you need to perform a left Join between Artist A and Music M (which makes sense to me from the point of view of sets):

select a.nome_artista, count(*) as numero_musicas 
  from artista a left join musica m on m.id_artista = a.id_artista
 group by a.nome_artista
  • I do not understand why it was voted down. The boy needs the data of the artists with the songs. The left Join needs to be done between the two tables because eventually an artist may not have any registered music.

  • I got here what I needed, fought

  • what I’m seeing here now, is to pull up the date information from the most recent song

  • @diegoAlves, mark as solved if your question has solved?

  • @Diegoalves, can you explain this latest music question better? You want the query to return the artist data and a column with the date of the most recent song? Or artist data + latest music data?

  • So, the songs have the dates, I need to bring the information of the older songs and the newer ones. i tried to use max and min but brings information with the name of an artist only with all the dates being that are 3 artists with different names

  • Right, you want to list the songs, with their respective artists and ordered by the song’s inclusion date?

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.