[Wolves] MySQL - equi-join DISTINCT

Philip Harper ph004h7245 at blueyonder.co.uk
Wed Jul 18 12:53:00 BST 2007


No, not certain columns, certain records, so that there will be no 
records which have the same value for username, i.e. no duplicates.

Alastair Battrick wrote:
> 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





More information about the Wolves mailing list