Hello,
I have a Visits table with IPs and Dates. Each time a user visits a page, its IP is inserted into the Visits table. I would like to get the most recently inserted IP after a GROUP BY Ip.
As you can't ORDER BY then GROUP BY, I don't know how to do that. "SELECT * FROM Visits ORDER BY InsertDate GROUP BY Ip" doesn't work.
The solution I found was to create 2 table, one that stores the visits and an other, LastVisits, that store the most visits:
LastVisits = Ip, LastVisitDate
So first time a user visits the page, its IP is inserted in both tables. But after that, each time it visits the page, its IP is only inserted into Visits, and the LastVisitDate field of LastVisits is just updated.
Is there anyway to do that with MySQL ? Without using 2 tables ? Maybe somekind of "GROUP BY LAST"...
Thanks,
JM