There is no result and no error when I try the following locally:
select
a,
bunch,
of,
fields
from import where id in (
SELECT distinct t1.id
FROM import t1 inner join import t2
on t1.programid = t2.programid and t1.sku = t2.sku
where t1.lastupdated < t2.lastupdated
)
This query is part of a query to copy old records to archive this is the part fetchng the data that needs to be moved.
When I run the whole thing in cpanel’s phpmydmin nothing happens, no error and no records are copied, when I run the statament that only gets the data nothing is returned, the page just sticks in loading and that’s it.
There are over a million records and 2/3 needs to be archived, I have to use cpanel that has phpmyadmin but think it’s unfit to run queries like that. When combined with “insert into” the above statement locks up the phpmyadmin session for 2 hours but no records are copied.
I have have phpmyadmin do this on queries wit subselects on some versions of it.
However try this SQL, which should do the same but might be more efficient.
Edited to add the below code to retrieve records which do not have the latest lastupdated for each programid / sku