I want to update a field in one table with the count of records in another table but perform the update only on records where the count is > 0.
which tries to update records and set them null if there are no records.Code:
update users set numvotes = (SELECT count(reviewid)
WHERE users.userid = reviews.userid
AND reviews.type = 'V' group by userid)