Picture this… a person adds a row of data about a computer into mysql and he again adds another row of essentially same row of data except that the date is different where each date is always stamped with the insert.
I want to be able to eliminate duplicates and show only the most recent row.
Let’s say we have a “computers” table with 3 fields: ID, COMPUTER, DATEADD
inside the table goes like this
1, dell, 2010-10-09
2, dell, 2011-10-10
3, gateway, 2010-03-03
4, dell, 2010-02-02
simple, ok… how do I get rid of dups of dell and only get dell with the latest date?
I tried this query:
SELECT *
FROM `computers`
GROUP BY computer
ORDER BY dates ASC
it doesnt perform as I expect – the date is not the latest.
Use
DESCinstead ofASC:UPDATE 1
Another shot:
but some problems might arise, if you have two or more entries of the same computer for one date.