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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:07:38+00:00 2026-06-16T08:07:38+00:00

So I have the following query: ‘SELECT *, upload.id AS id, report.id AS report_id,

  • 0

So I have the following query:

'SELECT *, upload.id AS id, report.id AS report_id, (SELECT COUNT(*) 
    FROM upload WHERE report.upload_id = upload.id) AS nums FROM upload 
    LEFT JOIN report ON upload.id=report.upload_id WHERE private="0" '

I am having an issue with how the reports for each upload are being counted. This query needs to count all the reports for a given upload, and return all the uploads when fetched. For some reason every time that a new report is inserted instead of being added to the total count I get a duplicate upload. See the image below:

enter image description here

Notice how console (1).png shows up three times for each report that correlates to the given upload…really I want it to show up once and then the count on the side should be ( 3 ). Any help would be much appreciated!!

  • 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-16T08:07:41+00:00Added an answer on June 16, 2026 at 8:07 am

    SQL Fiddle for testing.

    Just use a left join and count the report.upload_ids

    select u.filename, u.filesize, COUNT(r.upload_id) as reports
    from upload u
    left join report r on u.id=r.upload_id
    group by u.id, u.filename, u.filesize
    

    I left out where private = "0", since you didn’t specify where it belongs to.

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

Sidebar

Related Questions

I have the following query: SELECT `people`.`surename`, calcWeight(`people`.`surname`,'kiera',6) as `weight` FROM `people` LEFT JOIN
i have following query SELECT *, count(jx_commissions.commission_amount) AS summe FROM jx_members INNER JOIN jx_commissions
I have the following query SELECT COUNT(*) FROM Table1 WHERE Column1 IN (SELECT Column1
I have the following query: SELECT dbo.Enquiries.EnquiryID, COUNT_BIG(dbo.Enquiries.EnquiryID) AS AttachedLines FROM dbo.Enquiries INNER JOIN
I have the following query SELECT ID, TestReason FROM Test as t INNER JOIN
I have following query in PostgreSQL: SELECT COUNT(a.log_id) AS overall_count FROM Log as a,
I have following query select id, nameOfPet, count(fed) from petLover, pets where id =
I have following MySQL query: (SELECT c.Channel as name, count(*) as total_episode FROM (
I have following SQL Query SELECT * FROM KDMS_dynamic vd INNER JOIN KDMS_definition tblKDMS
I have following query working : SELECT COUNT(id), AgeRange FROM ( select id, case

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.