开发者

How do I get just one result when running a sql query?

SELECT user_ids FROM `items开发者_C百科` 

When I run that query, if a user has multiple items listed, I get the user_id listed that many times, but what I really want is just ONE user_id for each so it basically represents all the user_ids who have >1 entry in the items table (and what I really want is the corresponding email)


If I understand correctly you want to use distinct

SELECT DISTINCT user_ids FROM items


Select Distinct user_ids FROM items 


From your context of > 1 entry (ie: more than 1 entry), you'll need a group by, not just distinct... distinct will include everyone, even if they ONLY have ONE entry

select User_IDs
   from items
   group by User_IDs
   having count(*) > 1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜