I have a service which has a referrer system. There's table users in service's database which contains id and referrers columns. Column referrer contains a string of referrer ids that separated by ,. Here's an example data from this table:
+------+---------------+
| id | referrers |
+------+---------------+
| 1 | 1 |
| 7 | 1 |
| 8 | 1 |
| 9 | 1 |
| 10 | 7,1 |
| 11 | 1 |
| 12 | 7,1 |
| 13 | 1 |
| 14 | 9,1 |
| 20 | 7,1 |
I need smt like: SELECT id, login FROM users u WHERE id IN (SELECT id FROM users u1 WHERE *referrers count more than 1000*), but I don't understand what should I use in *..*. To see this situation more clearly, I need to get the current user id from the first query and add it to the subquery into the %LIKE% statement, but how? Like:
`SELECT
id, login
FROM users u
WHERE id IN
(SELECT id FROM users u1 WHERE count((SELECT * FROM users u2 WHERE refer LIKE %u1.id%) > 1000)`
But how to do it in right way?