I copied some records from one table to another with this query:
insert into pages_finished (keyword,pages,resultlist,done,current)
select keyword,pages,resultlist,done,current
from pages_done o
where (select count(*) as totalPages from pages_done x where x.keyword = o.keyword)-1 = pages
Now I want to delete the same records from the source table, I thought it would be simple:
delete from pages_done o
where (select count(*) as totalPages from pages_done x where x.keyword = o.keyword)-1 = pages
but that will not work. Can someone tell me how to do this right?
After @bgdrl's answer, I think about starting only select, get the identifier of all the records that need to be copied, and then deleted; but I think there should be a simpler solution, anyone?
Even if the marked @bgdrl answers as the correct answer, it’s only because of this fact.
Who cares what I did: I made the same choice that I started (but chose only the id column, since selecting all the columns would kill my bad computer), exported it to INSERT STATMENTS(using mysqlworkbench), opened a text file in notepad, replaced everything INSERT INTO... with DELETE FROM WHERE ID=, and run this query in mysql.
I'm so stupid using this path, but apparently had no other choice.