there is my code sample that deletes data from queue_db,I need code which inserts queue_db values to staff_db table.enter image description here
1 Answers
You can use SQL query
Copy all record one table to another
insert into staff_db select * from queue_db
This will transfer the data one table to another, later you can delete records conditionally from first table
If the columns names are different then
Copy all record one table to another with column name alias
insert into staff_tb(column1, column2, column3) select c as column1, b as column2, d as column3 from queue_db
where c,b,d are the columns in the second table
If you want to filter it with condition then add where
at the end of the query with <tablename.columnname> = <value>
Copy all record one table to another without duplicates
To prevent duplicates, you can use this answer Prevent Duplicate I don't want repeat the same answer here
If you want copy those data into fresh new table like doing a backup then
Copy all record one table to a fresh new table
select * into newtable from queue_db
Then you run delete query for table which you copied from
Delete all records from a table
delete from queue_db

- 3,824
- 2
- 22
- 45
-
-
-
thank you <3 I have 1 more problem now,how can I insert this entry to new table and also delete from previous table? – Gigz Apr 02 '20 at 12:45
-
you need to run two query the `into` query and `delete` query one after one, updated the answer – Dickens A S Apr 02 '20 at 12:53