This is more of an SQL question. I have very little knowledge in MySQL

In the review_store table, there are two columns: review_id and store_id

If I had to replace 1 with 2 I would do this:

UPDATE review_store 
SET store_id = '2' 
WHERE store_id = '1'

What would be the SQL query if I wanted to copy/duplicate all values of 1 in store_id to a new row with a value of 2

Thanks a lot!


I figured it was more of an SQL question than a Magento so I asked on the regular Stackoverflow as well, here's the answer

INSERT INTO review_store
SELECT review_id, '2' as Store_id
FROM review_store
WHERE Store_id = '1'

I also had to apply the same logic to the review_entity_summary table, which has 6 columns: primary_id, entity_pk_value, entity_type, reviews_count, rating_summary and store_id. The first columns is PRIMARY so I had to skip it so it'll automatically create a new value. SQL query:

INSERT INTO `review_entity_summary`(`entity_pk_value`,`entity_type`,`reviews_count`,`rating_summary`,`store_id`)
SELECT `entity_pk_value`,`entity_type`,`reviews_count`,`rating_summary`,'2'
FROM `review_entity_summary`
WHERE `store_id` = '1'

Then in order to have the STARS displayed I had to go to catalog > reviews and ratings > manage ratings, click on the rating and add the new store.

I hope this can help others with the same goal.


| improve this answer | |

Try this also,

CREATE TEMPORARY TABLE tmptable SELECT * FROM review_store WHERE store_id = 1;

UPDATE tmptable SET store_id = 2 WHERE store_id = 1;

INSERT INTO review_store SELECT * FROM tmptable WHERE store_id = 2
| improve this answer | |
  • Will this work given primary key values? – benmarks Jul 7 '15 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.