In my db, uid is the autoincrement value indicates user ids and u_follow shows the user that follows other users with their uid seperated comma. i want to count that how many followers has each user. How can i do that ?
uid u_follow
1 2,3
2 1,3
3 1,2
4 NULL
5 2,3,4
Store one value per column, otherwise you just can’t do relational queries. See this excellent discussion for an introduction to database normalization.
usersfollowersThen:
If you want to include users with no followers do something like: