I’m trying to import product data from different sellers, the data is imported to an import table with the following fields:
id=auto increment
sellerid=key to seller
sellerproductid=the product id a seller gives to a product
lastupdate=the date that this item is updated
So seller A can have Product id 22 witch is the same product as seller B having product id 55.
When seller A changes the price of product A there will be a line in the import. I currently have many “historical” lines and am only interested in getting the most current of the import
For example:
1 A 22 2012 01 22
2 A 22 2012 05 10
44 A 22 2012 11 10
I would like to archive the first 2 lines like so:
insert into archive ....
values ( select * from import where id in(
select id from import
where `lastupdate` < max(`lastupdate`)
group by sellerid, sellerproductid
)
I’m having trouble finding the right mysql statement to get the id’s of the older records.
This should give all but latest entry :