[Wolves] MySQL - equi-join DISTINCT

Philip Harper ph004h7245 at blueyonder.co.uk
Wed Jul 18 15:39:23 BST 2007

Ah now found another way to do it without joining tables and complex 
SQL, I wanted to display on my site a list of users who recently logged 
in, but I can do it much easier to by using some very simple SQL to 
return users who logged in during the last month, and limiting it to 30.

Alastair Battrick wrote:
> Philip Harper wrote:
>> No, not certain columns, certain records, so that there will be no 
>> records which have the same value for username, i.e. no duplicates.
>>>> $last = mysql_query("SELECT DISTINCT * FROM user, userlog WHERE 
>>>> userlog.username = user.username LIMIT 0, 20") or die(mysql_error());
> So start with this, and add more columns until you are retrieving the 
> columns you need
> SELECT DISTINCT user.username FROM user, userlog WHERE 
> userlog.username = user.username

More information about the Wolves mailing list