Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sas0riza
Yak Posting Veteran
56 Posts |
Posted - 2008-11-14 : 09:56:12
|
[code]update Moviesset Movies.TotalInStock = Movies.TotaIInStock + 1from Videoswhere Movies.MovieID = Videos.MovieID[/code]My 2 tables:Movies (MovieID,...,TotalInStock)Videos (VideoID,MovieID,...)The problem is say if I have a record in the Movies table already andthe count is correct. But if I add another movie and then add thevideo(s), the new movie count gets incremented plus increments theother movie.e.g., BEFOREMovieID TotalInStock11 3e.g, AFTERMovieID TotalInStock11 412 1What am I doing wrong? Thanks |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-11-14 : 10:04:59
|
You are updating same video/movie twice because the JOIN criteria is fulfilled.Someone suggested w3schools to you. I suggest you read up on those pages a bit. E 12°55'05.63"N 56°04'39.26" |
|
|
sas0riza
Yak Posting Veteran
56 Posts |
Posted - 2008-11-14 : 10:14:39
|
quote: Originally posted by Peso You are updating same video/movie twice because the JOIN criteria is fulfilled.Someone suggested w3schools to you. I suggest you read up on those pages a bit. E 12°55'05.63"N 56°04'39.26"
Thanks, I did check out w3schools. |
|
|
|
|
|