deadpool42
Programmer
- May 24, 2004
- 40
Here's the query I'm trying to figure out:
I'm guessing the problem is referring to the main table from withing the subquery, but I can't think of a way to do this with JOINs.
What I'm trying to do is rebuild a table of quote ratings, converting everything that was previously rated greater than 2 (in the vb_quoteratings table) to be a rating of 1 and add them all up in the vb_quotes table. The only way I know of would be to run hundreds of queries (one for each quoteid).
Code:
UPDATE vb_quotes AS quotes
SET quotes.rating = quotes.rating +
( SELECT COUNT( * ) FROM vb_quoteratings AS ratings
WHERE ratings.quoteid = quotes.quoteid AND ratings.rating > 2 )
I'm guessing the problem is referring to the main table from withing the subquery, but I can't think of a way to do this with JOINs.
What I'm trying to do is rebuild a table of quote ratings, converting everything that was previously rated greater than 2 (in the vb_quoteratings table) to be a rating of 1 and add them all up in the vb_quotes table. The only way I know of would be to run hundreds of queries (one for each quoteid).