Reputation: 3098
Trying to select all columns but avoid more than 1 same userid.
$result = mysql_query("select *, DISTINCT userid from ringtones where deletedbyuser='0' and (lang='$lang' or lang='en') order by id desc limit 10");
Please help.
Table structure:
id int(10)
userid int(10)
artist varchar(100)
title varchar(100)
lang varchar(2)
public int(1)
status int(1)
deletedbyuser int(1)
Upvotes: 0
Views: 90
Reputation: 129744
You can
select r.* from ringtones r
inner join (select MIN(id) as id, userid from ringtones
where deletedbyuser='0' and (lang='$lang' or lang='en')
group by userid) s
on r.id = s.id
order by r.id desc
limit 10
this will pick the first one added if there are more than one.
Upvotes: 3