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

  • SEARCH
  • Home
  • 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 9152091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:57:32+00:00 2026-06-17T11:57:32+00:00

I have a Database with the following two tables, member, POSTS I am looking

  • 0

I have a Database with the following two tables, member, POSTS I am looking for a way to get the count of how many posts a user has.

enter image description here
(Source: https://i.stack.imgur.com/FDv31.png)

I have tried many variations of the following SQL command with out any success. instead of showing the count of posts for a single user it shows a single row with all the posts as the count.

In the end I want something like this

enter image description here
(Source: https://i.stack.imgur.com/EbaEj.png)

  • 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-06-17T11:57:34+00:00Added an answer on June 17, 2026 at 11:57 am

    Might be that I’m missing something here, but this query would seem to give you the results you want:

    SELECT member.ID,
           member.Name,
           (SELECT COUNT(*) FROM Posts WHERE member.ID = Posts.user_id) AS total
    FROM   member;
    

    I have left comment out of the query as it is not obvious what comment you want to be returned in that column for the group of comments that is counted.

    See a SQL Fiddle demo here.

    Edit
    Sorry, misinterpreted your question 🙂 This query will properly return all the comments, along with the person who posted them and the total number of comments that the person made:

    SELECT Posts.ID,
           member.Name,
           (SELECT COUNT(*) FROM Posts WHERE member.ID = Posts.user_id) AS total,
           Posts.comment
    FROM   Posts
    INNER JOIN member ON Posts.user_id = member.ID
    GROUP BY Posts.ID, member.Name, member.ID, Posts.comment;
    

    See an updated SQL Fiddle demo here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Database with the following two tables, USERS, POSTS I am looking
I have two tables in my database. The first one, [nodeActivity] has the following
I have two database tables: Definitions table has the following columns: Id, Category Sample
I have a simple database with two tables. Users and Configurations. A user has
I have the following two tables in my mysql database. Table Name: groups id
I have a database with two tables, tblPlayers and tblMatches. tblPlayers contains the following
I have two database tables with the following structure: actions: action_id int(11) primary key
Consider the following scenario We have a simple database that involves two entities: user
I have a database with two tables, component_psar and tbl_info. The component_psar table has
I have a database that has two tables. These two tables are defined as:

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.