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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:52:24+00:00 2026-05-23T23:52:24+00:00

I have the following queries – SELECT COUNT(capture_id) as count_captures FROM captures WHERE user_id

  • 0

I have the following queries –

SELECT COUNT(capture_id) as count_captures 
  FROM captures 
 WHERE user_id = 9

…returns 5

SELECT COUNT(id) as count_items 
  FROM items 
 WHERE creator_user_id = 9

…returns 22

I tried the following query –

   SELECT COUNT(capture_id) as count_captures, 
          COUNT(items.id) as count_items 
     FROM captures 
LEFT JOIN items ON captures.user_id = items.creator_user_id 
    WHERE user_id = 9

…but it returns two columns both with 110 as the value. I would want 5 in one column and 22 in the other. What am I doing wrong?

  • 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-23T23:52:25+00:00Added an answer on May 23, 2026 at 11:52 pm

    My knee-jerk is a subquery:

    select count(capture_id) as count_captures, 
        (select count(id) as count_items
             from items i where i.creator_user_id = captures.user_id) as count_items 
    from captures 
    where user_id = 9
    

    I’m not really sure what you can do to avoid this. You’re seeing expected (and generally desired behavior).

    Of course, if you know that the ID’s in both won’t repeat themselves, you can use distinct:

    SELECT COUNT( DISTINCT capture_id) as count_captures, 
          COUNT( DISTINCT items.id) as count_items 
    FROM captures 
    LEFT JOIN items ON captures.user_id = items.creator_user_id 
        WHERE user_id = 9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following 2 queries: SELECT CARD_ID,COUNT(CARD_ID) AS CNT1 FROM G_CARD_SCHEDULE GROUP BY
I have the following MySQL queries: Query #1: SELECT imgURL, imgTitle, FROM images Query
I have following queries: Model.RampActiveHour rah = null; var defaultWeekQuery = QueryOver.Of<Model.RampAdditionalDefaultWeek>() .Where(adw =>
I currently have the following array, Array (1) 0 => Array (5) productid =>
I have the following SQL Server 2008 query that works for all of my
i have to show running total with the total column in my application ...
I am familiar with inapppurchase that lets you use additional features of the app.But
I would like to write a documentation for one of my Django based project.
I am new to develop touch pad applications. I am using Enyo framework and

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.