SQL query for products ratings and reviews in my store

Hello everyone,

I would like the child products in my store to inherit the reviews and ratings of the parent product (ID 22).

Before I do anything stupid, I'd like to make sure that the following SQL query is correct:

SELECT
child.virtuemart_product_id AS child_product_id,
rv.vote,
rrv.comment,
rrv.review_rating
FROM
(SELECT 1 AS virtuemart_product_id UNION ALL
SELECT 23 UNION ALL
SELECT 16 UNION ALL
SELECT 15 UNION ALL
SELECT 26 UNION ALL
SELECT 25 UNION ALL
SELECT 13 UNION ALL
SELECT 2 UNION ALL
SELECT 30 UNION ALL
SELECT 28) child
LEFT JOIN
ou7s_virtuemart_rating_votes rv
ON
rv.virtuemart_product_id = 22
LEFT JOIN
ou7s_virtuemart_rating_reviews rrv
ON
rrv.virtuemart_product_id = 22;

We have no idea, we don't even know what the query supposed to do nor does it gives the expected result.

Why don't you execute it see it gives you the required result ?

1 Like