Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5943261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:22:12+00:00 2026-05-22T16:22:12+00:00

In my db, uid is the autoincrement value indicates user ids and u_follow shows

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:22:12+00:00Added an answer on May 22, 2026 at 4:22 pm

    Store one value per column, otherwise you just can’t do relational queries. See this excellent discussion for an introduction to database normalization.

    users

    uid
    ...
    

    followers

    uid u_follow
    1   2
    1   3
    2   1
    2   3
    3   1
    3   2
    5   2
    5   3
    5   4
    

    Then:

    select u_follow, count(*) as num_followers from followers group by u_follow
    

    If you want to include users with no followers do something like:

    with a as (
      select u_follow, count(*) as num_followers
      from followers group by u_follow
    )
    select users.uid, coalesce(a.num_followers,0)
    from users outer join a on users.uid = a.u_follow
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can assign a sequence value to a field UID which is NUll
I have three tables: Project: ... relations: User: local: authorId foreign: id Users: class:
I have 3 tables: Users - uID (INT AUTO_INCREMENT), name (VARCHAR) Movies - mID
I have two tables, one that stores user earnings and another that stores the
Given the following table structure: CREATE TABLE user ( uid INT(11) auto_increment, name VARCHAR(200),
I have a table(users) with columns as id INT AUTOINVREMENT PRIMARY uid INT index
I have a query that select the top 5 of the UID that most
I understood that UID changes but the Message-Id will not be changed during any
I have these relationships: User(uid:integer,uname:varchar) , key is uid Recipe(rid:integer,content:text) , key is rid
I have two tables in my MySQL database, users and tweets, as follows: TABLE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.