Re: Re: do not display dublicated entries

From: Date: Fri, 16 Mar 2007 16:23:41 +0000
Subject: Re: Re: do not display dublicated entries
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-43293@lists.php.net to get a copy of this message
On 3/14/07, Niel Archer <spamfree@blueyonder.co.uk> wrote:
Hi I have tried everything except of the one that forms the date in one field and use the DISTINCT for ip and date. It works for me. I use it for essentially the same job, listing most recent visit to a location (not IP, but physical venue). Have you tried adapting it to your needs, such as: $query = "SELECT DISTINCT ip, day, month, year FROM tracker WHERE page = 'index' ORDER BY tracker.year DESC , tracker.month DESC , tracker.day DESC LIMIT 0, 20"; Niel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
try grouping by IP and selecting the max date value SELECT IP,max(date) AS latestvisit FROM table GROUP BY IP

« previous php.db (#43293) next »