 <p>If the data is re-loaded every day, then you should just fix it when it is reloaded.</p> <p>Perhaps that is not possible. I would suggest the following approach, assuming that the triple <code>url</code>, <code>shop</code>, <code>InsertionTime</code> is unique. First, build an index on <code>url, shop, InsertionTime</code>. Then use this query:</p> <pre><code>select ap.* from AllProducts ap where ap.InsertionTime = (select InsertionTime from AllProducts ap2 where ap2.url = ap.url and ap2.shop = ap.shop order by InsertionTime limit 1 ); </code></pre> <p>MySQL does not allow subqueries in the <code>from</code> clause of a view. It does allow them in the <code>select</code> and <code>where</code> (and <code>having</code>) clauses. This should cycle through the table, doing an index lookup for each row, just returning the ones that have the minimum insertion time.</p>