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 8916535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:15:44+00:00 2026-06-15T05:15:44+00:00

Please refer the db table image. I want to count type with value ‘Q’

  • 0

Please refer the db table image.

enter image description here

I want to count type with value ‘Q’ for each user id. I am confused either whatever I have written is correct or not.

"SELECT COUNT(type),userid FROM '$db_prefix'posts WHERE type=Q GROUP BY userid";

So where it will display total number of Q for x user id like below :

userid 1 has 25 Q
userid 2 has 11 Q
....

Same way for A and C but I think if I will get for Q than it will work in the same way for A and C.

  • 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-15T05:15:45+00:00Added an answer on June 15, 2026 at 5:15 am

    You can actually get it for each type with a single query. Like this:

    SELECT type, userid, COUNT(*) AS `n` FROM posts GROUP BY type, userid;
    

    This query groups those rows that have the same value of BOTH type and userid.

    Echo statement:

    echo $q['userid'] .' has '. $q['n'] $q['type'] .' question';

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

Sidebar

Related Questions

Please refer to this fiddle . While scrolling down, the table cells appear in
Please refer to the image below - I'm not using NavigationViewController. Is there a
Please refer to this background question. After constructing this COUNT, how would I then
Please refer to the image at: http://i50.tinypic.com/svgg2h.jpg I have defined CSS color(#000000) for my
Please refer below script declare @table1 table ( col1 int ) insert into @table1
I want to merge the results of two tables in to one. Please refer
Please refer the below script declare @table1 table ( col1 int ) declare @table2
Please refer to this SQLFiddle: http://sqlfiddle.com/#!2/9db4f Table 'rate' stores hourly chargeout rates for job
Please refer the fiddle http://jsfiddle.net/HCqsM/5/ Here By clicking the 'click' link for the first
Please refer to this post. I have become able to configure my web.config file

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.