[Wolves] MySQL - equi-join DISTINCT

Alastair Battrick al at aj8.org
Wed Jul 18 12:42:13 BST 2007


Philip Harper wrote:
> $last = mysql_query("SELECT DISTINCT * FROM user, userlog WHERE 
> userlog.username = user.username LIMIT 0, 20") or die(mysql_error());
> 
> This SQL works, but still returns 4 records, the total number of records 
> in the table userlog, so the DISTINCT clause isn't filtering out the 
> duplicates in table userlog, anyone any ideas where DISTINCT goes in the 
> join?

You are telling the query to return "*" ie everything. I expect you want 
to restrict the results to certain columns of the user table. DISTINCT 
is in the correct place
-- 
Alastair Battrick
http://www.aj8.org



More information about the Wolves mailing list