mysql - SQL query doesn't work when using UNION? -
Here is a snapshot of the query that does not work since joining the union.
fin05_usager.idUsager, (select sum (nombreReputation) to be elected as nombreReputation (yoga as nombreReputation the fin05_usager_reputation (nombreReputationGagner) where fin05_usager_reputation.idUsager = fin05_usager.idUsager Group by fin05_usager_reputation.idUsager UNION select sum (cc_badge.valeurEnReputation) from fin05_usager_badge.idBadge where cc_badge, fin05_usager_badge as nombreReputation = cc_badge.idBadge and fin05_usager_badge.idUsager = fin05_usager.idUsager) as repuUnion) as repu from fin05_usager where fin05_usager .idUsager = 6
error is: # 1054 - Unknown column 'pen00f_usager.idUsager' in 'pen'
Gar I use deletes fin05_usager.idUsa am Jir and directly '6'.
If I remove the association and choose one of only 2, then it works (what if I for the second, fin05_usager_badge.
for the fun05_user_rputation or CC_base. Why does the union use an error about finding the idUsager and without any errors without the union?
Simplified schema:
fin05_usager: idUsager int (8)
fin05_usager_reputation: idUsager integer (8), nombreReputationGagner integer (4)
cc_badge: idBadge integer (4), valeurEnReputation full (4)
Fin05_usager_badge: idUsager int (8), idBadge int (4)
Note:
I can not directly subquery in the query The selection is to be used within a subquery because in reality, the query is too large and is already included in the group, etc.
When you say that the removal of the union causes the work to be done, then I am betting that you are removing it specifically:
Union SELECT SUM (Cc_badge.valeurEnReputation) of nombreReputation The cc_badge in form, fin05_usager_badge where fin05_usager_badge.idBadge = cc_badge.idBadge and fin05_usager_badge.idUsager = fin05_usager.idUsager
This piece is fin05_usager.idusager
The mysql error is mentioning that sub-entry is allowed at only one level - there is no point in both ways that you should not really do a SELECT within SELECT clause. Here's how I have your query re:
fu.idUsager, a.nombreReputation + b.nombreReputation select Join as repuunion the fin05_usager Fu (from nombreReputation as fur.idusager, SUM (fur select .nombreReputationGagner) Where fin05_usager_reputation fur fur.idUsager = fin05_usager.idUsager Group select by fur.idUsager) join a = on a.idusager fu.idusager (fub.idUsager, SUM (ccb.valeurEnReputation) nombreReputation cc_badge CCB the fub.idUsager by = Ccb.idbadge GROUP aS join fin05_usager_badge fub on fub.idbadge) b.idusager = fu.idusager WHERE fu.idUsager = 6
Comments
Post a Comment