Hey,
lang’ ist’s her seit meinem letzten bplaced Besuch
Nun brauch ich doch mal wieder eure Hilfe
Es geht um folgenden Query:
SELECT
d.cpu, d.gpu, d.mb, p.id, p.uid, p.name,
COUNT(r.id) as total_votes,
SUM(r.value) as total_value
FROM pcprofil_profiles p
INNER JOIN pcprofil_ratings r
ON r.id = CONCAT('viewprofile', p.id)
INNER JOIN pcprofil_profiles_data d
ON d.pid = p.id
HAVING
(SUM(r.value) / COUNT(r.id) > 4)
ORDER BY
SUM(r.value) / COUNT(r.id) DESC,
COUNT(r.id) DESC
LIMIT
0,10
Das Problem ist nun, dass das INNER JOIN pcprofil_ratings r
ON r.id = CONCAT(‚viewprofile‘, p.id) wohl nicht so richtig will, denn dieser Query gibt als ‚total_votes‘ 9 zurück, obwohl er eigtl. 2 für bspw. ID: ‚viewprofile33‘ zurückgeben müsste.
Ich hoffe, ihr findet den Fehler
Danke.
EDIT:
Hier mal als Beispiel die Tabelle ‚pcprofil_ratings‘:
[code]CREATE TABLE IF NOT EXISTS pcprofil_ratings
(
id
varchar(300) NOT NULL,
value
int(11) NOT NULL,
uid
int(11) NOT NULL,
KEY id
(id
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO pcprofil_ratings
(id
, value
, uid
) VALUES
(‚article2‘, 5, 1),
(‚viewprofile33‘, 5, 1),
(‚viewprofile2‘, 5, 55),
(‚viewprofile2‘, 5, 56),
(‚viewprofile2‘, 5, 57),
(‚viewprofile2‘, 5, 58),
(‚viewprofile2‘, 5, 59),
(‚viewprofile2‘, 5, 60),
(‚viewprofile2‘, 5, 1),
(‚viewprofile33‘, 1, 2);[/code]
Und hier das Ergebnis des oben geposteten Query:
Wie ihr seht ist viewprofile33 angeblich das am besten bewertete Profil