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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:23:05+00:00 2026-06-10T21:23:05+00:00

So I’m not the best at SQL I have this complicated MySQL query that

  • 0

So I’m not the best at SQL I have this complicated MySQL query that I’m lost in. The part I don’t understand is, all of the results that come out of the partial query above UNION are multiplied by 8. How is this possible? Why are they being multiplied by 8 and how can I stop it? I also have a few other queries very similar to this one and they all have this same problem. Any ideas on why this could be happening would be greatly appreciated. Thank you!

SELECT best_thrown
    FROM(
        SELECT CASE WHEN rageup_echelon.party_id IS NULL THEN 0 ELSE SUM(CASE WHEN rageup_echelon.echelon_vote = 1 THEN 5 ELSE 0 END) - SUM(CASE WHEN rageup_echelon.echelon_vote = 0 THEN 3 ELSE 0 END) END AS best_thrown
        FROM rageup_parties LEFT JOIN rageup_echelon ON rageup_parties.party_id = rageup_echelon.party_id
                            LEFT JOIN rageup_team_hosts ON rageup_parties.party_team_id = rageup_team_hosts.team_id
        WHERE rageup_team_hosts.team_id = 1 || rageup_team_hosts.team_id = 2 || rageup_team_hosts.team_id = 3
        AND rageup_parties.party_status = 'approved'
        AND rageup_parties.party_invites = 'public'
        AND rageup_team_hosts.user_id = 1
        GROUP BY rageup_parties.party_id
        UNION
        SELECT CASE WHEN rageup_echelon.party_id IS NULL THEN 0 ELSE SUM(CASE WHEN rageup_echelon.echelon_vote = 1 THEN 5 ELSE 0 END) - SUM(CASE WHEN rageup_echelon.echelon_vote = 0 THEN 3 ELSE 0 END) END AS best_thrown
        FROM rageup_parties LEFT JOIN rageup_echelon
        ON rageup_parties.party_id = rageup_echelon.party_id
        WHERE rageup_parties.party_host_id = 1
        AND rageup_parties.party_status = 'approved'
        AND rageup_parties.party_invites = 'public'
        AND rageup_parties.party_team_id = 'user'
        GROUP BY rageup_parties.party_id
        ORDER BY best_thrown DESC
        LIMIT 1
    ) AS T
  • 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-10T21:23:07+00:00Added an answer on June 10, 2026 at 9:23 pm

    For debugging, run just the first query without the GROUP BY stuff and look at the underlying rows that are returned.

    Also note that you’re using LEFT JOIN from rageup_parties to rageup_team_hosts – making matching team_hosts entries optional – but then requiring team_id to be set to non-NULL values in the WHERE clause. If you know the data is dirty enough to require the LEFT JOIN, move those conditions into the ON clauses for each LEFT JOIN.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question

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.