1

I'm a beginner in SQL however I have two tables one LibraryTable where I have list of songs, and another table called Playlist, I'm using netbeans to program a prototype jukebox, and I can add songs from the Library to my playlist, and I can increment playcount of all the song that where added to the playlist, however both LibraryTable and Playlist have a column called playcount, I want know how I would go about updating the playcount column in LibraryTable with the the playcount column in my Playlist table.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

2

You can do joins in UPDATE statements.

UPDATE L
SET L.Playcount = P.Playcount
FROM Playlist P
INNER JOIN LibraryTable L
ON P.SongID = L.SongID
TTeeple
  • 2,913
  • 1
  • 13
  • 22
  • You are brilliant thank you worked perfectly, except i just had to change SongID to just ID lol, but thanks for everyones help. – user3012997 Feb 14 '14 at 14:41