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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:13:11+00:00 2026-05-12T19:13:11+00:00

Here is the snapshot of the query that doesn’t work since I added the

  • 0

Here is the snapshot of the query that doesn’t work since I added the Union.

SELECT fin05_usager.idUsager,
       (SELECT sum(nombreReputation) as nombreReputation
          FROM (SELECT SUM(nombreReputationGagner) as nombreReputation
                 FROM fin05_usager_reputation 
                WHERE fin05_usager_reputation.idUsager = fin05_usager.idUsager
             GROUP BY fin05_usager_reputation.idUsager
        UNION
                SELECT SUM(cc_badge.valeurEnReputation) as nombreReputation
                  FROM cc_badge, fin05_usager_badge
                 WHERE fin05_usager_badge.idBadge = cc_badge.idBadge
                   AND fin05_usager_badge.idUsager = fin05_usager.idUsager) as repuUnion    
       ) as repu
 FROM fin05_usager
WHERE fin05_usager.idUsager = 6

The error is : #1054 – Unknown column ‘fin05_usager.idUsager’ in ‘where clause’

If I remove the fin05_usager.idUsager and use directly ‘6’ it does work.

If I remove the union and use only one of the 2 select it works (what ever if I take the FROM fin05_usager_reputation or the other one FROM cc_badge, fin05_usager_badge.

Why when using the UNION the error about finding the idUsager appear and without the union no error is found?

Schema simplified:

fin05_usager: idUsager int(8)

fin05_usager_reputation : idUsager int(8), nombreReputationGagner int(4)

cc_badge : idBadge int(4), valeurEnReputation int(4)

fin05_usager_badge : idUsager int(8), idBadge int(4)

Note:

I cannot do the subquery directly in the query. I have to use it inside a subquery in the select because in real, the query is very big and already contain Group, etc.

  • 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-12T19:13:11+00:00Added an answer on May 12, 2026 at 7:13 pm

    Alright,

    The only way I found for the moment without doing a Group By in the main query (since in the real situation I can’t because it does contain already a Group By clause) is to do it in 2 and to merge it with the code… not exaclty what I would like but it works at least:

        SELECT fin05_usager.idUsager,
    
                    (SELECT sum(nombreReputationGagner) as nombreReputation1
                    FROM fin05_usager_reputation 
                    WHERE fin05_usager_reputation.idUsager = fin05_usager.idUsager
                    group by fin05_usager_reputation.idUsager) as nombreReputation1
                ,
                    (SELECT sum(cc_badge.valeurEnReputation) as nombreReputation2
                    FROM cc_badge,  fin05_usager_badge
                    WHERE fin05_usager_badge.idBadge = cc_badge.idBadge
                    AND fin05_usager_badge.idUsager = fin05_usager.idUsager) as nombreReputation2
    
        FROM 
            fin05_usager
            where fin05_usager.idUsager = 6
    

    In the code I sum the nombreReputation1 and nombreReputation2.

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

Sidebar

Related Questions

Here is a snapshot of my code: $fetchPictures = $PDO->prepare(SELECT * FROM pictures WHERE
I'm noticing that when I do a query such as the following: https://rally1.rallydev.com/analytics/1.27/41529001/artifact/snapshot/query.js?find={ _Type:
Why glibc and pthread library both defined same APIs ? Here is the snapshot
Here is my work environment: Eclipse Juno as IDE with maven2 plugin on it
here is a snapshot of my csv: alex 123f 1 harry fwef 2 alex
Here is the snapshot of repeater code. I have problems with geting all the
I'm having a really strange issue with watir-webdriver. Here's a snapshot of the input
Ok, So I have this query that is creating a new column (total) which
Here's the snapshot of the code: If the function testFields at Line:3 returns false,
I have a query that fetches employee's name, date, working hours, wage and calculate

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.