The task is the following. There is a page that needs to be duplicated several times, and all the records from the tables that correspond to it, well, of course, everyone’s IDs will then be changed to the correct one. Which option is the fastest and most convenient? So far, it has only occurred to me in each table to do an insert based on the query, and then go go to me, but I’ll be busy until the morning, there are about 10 tables and it will take a lot of time to play each one.

    1 answer 1

    INSERT INTO articles (text,author, ... ) SELECT (text, author, ... ) FROM articles WHERE id (1,2,3,4,5,6,7); 

    Something like that, in short, use INSERT ... SELECT

    http://dev.mysql.com/doc/refman/5.7/en/insert-select.html

    • INSERT INTO products (lp_id, title_ro, title_ru, title_en, pieces_in_pack, pieces_box, gros, lat, cant) SELECT lp_id, title_ro, title_ru, title_en, pieces_in_pack, pieces_box, gros, lat, cant FROM products WHERE lp_id =
    • That is, with each table to play like that, and with your hands then go change? - quaresma89
    • WHERE id IN (1,2,3,4,5,6,7); - Denis
    • The IDs themselves are put down automatically if the id field has an AUTO_INCREMET flag. And most likely he is. - FreeDooM
    • one
      You can try this: INSERT INTO articles (text, author, ip_id) SELECT (text, author, ip_id + 3) ... Well, that is, apply an arithmetic operation to the selected column, for example. - FreeDooM