Search code examples
mysqlsqlmagentoreview

SQL query: Copy all rows with Store_ID = 1


I have a table review_store with 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'

How do I copy/duplicate every row in which store_ID = 1 to Store_ID = 2 ?


Solution

  • I assume you mean create new records in the same table. Use INSERT SELECT

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