INSERT INTO mall_review (product_id, order_id, author, rating, title, content, image_url, store_id, helpful_count) VALUES (#{productId}, #{orderId}, #{author}, #{rating}, #{title}, #{content}, #{imageUrl}, #{storeId}, 0) DELETE FROM mall_review WHERE id = #{id} AND author = #{author} UPDATE mall_review SET helpful_count = COALESCE(helpful_count,0) + 1 WHERE id = #{id} UPDATE mall_product SET rating_avg = (SELECT COALESCE(ROUND(AVG(rating)::numeric,2),0) FROM mall_review WHERE product_id = #{productId}), review_count = (SELECT COUNT(*) FROM mall_review WHERE product_id = #{productId}) WHERE id = #{productId}