[Wolves] MySQL - equi-join DISTINCT

Alastair Battrick al at aj8.org
Wed Jul 18 12:57:25 BST 2007


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
-- 
Alastair Battrick
http://www.aj8.org



More information about the Wolves mailing list