Transfer records from a table into a MySQL table?

There is a need part of the data continuously transferred from the working table to the archive and remove them from working. It is clear that it is possible to write a query to SELECT then INSERT where you specify a bunch of fields, then DELETE from the first table, and whether it somehow means MySQL to do this? Replication does not offer, don't need an exact copy.
July 9th 19 at 12:56
4 answers
July 9th 19 at 12:58
Solution
INSERT INTO `table1` (`field1`, `field2`, ...) SELECT `field1`, `field2`, ... FROM `table2` WHERE ...;
DELETE FROM `table2` WHERE ...;
Oh, so it is possible, but between requests separators of some kind is necessary to put? It does not seem to subqueries, but just sequential queries? - Tyreek.Stoke commented on July 9th 19 at 13:01
: INSERT ... SELECT - Kenyatta commented on July 9th 19 at 13:04
July 9th 19 at 13:00
Solution
INSERT INTO Customers (CustomerName, Country)
SELECT SupplierName, Country FROM Suppliers;
July 9th 19 at 13:02
Solution
depending on the purpose, you can do either of two queries:
INSERT INTRO arhive_table (field1, field2) SELECT field1, field2 FROM table WHERE <here condition>;
DELETE FROM table WHERE <here condition>;
or to realize protezirovanie (this method will be the best) https://habrahabr.ru/post/66151/
The SELECT statement in the subquery to INSERT in this case will stand? Otherwise, how INSERT know what to insert? - Tyreek.Stoke commented on July 9th 19 at 13:05
Yes, we are talking the basis of "put all that in this sample" - Kenyatta commented on July 9th 19 at 13:08
July 9th 19 at 13:04
Solution
Means mysql can't do
There is only cron or Task Scheduler (depends on your OS)

Find more questions by tags MySQL