Reputation: 6062
I have a table called users
in my database, it have the following structure:
id (int)
username (varchar)
upline (int)
Now, if a user is a referral to another user, it's id
will be insterted into upline
My question is, how can I search, generally across my entire users table, for the users who have the same id
inserted into upline
, without having a specific id
?
Upvotes: 0
Views: 88
Reputation: 1271151
If I understand correctly, you basically just want a having
clause:
select upline, group_concat(id)
from users
where upline <> 0
group by upline
having count(*) = 100;
Upvotes: 1