codice:
1 SELECT
2 pts.userid,
3 pts.points,
4 com.value
5 FROM (
6 SELECT
7 c.value,
8 MAX(p.points) AS max_pts
9 FROM k6l0c_community_fields_values AS c
10 WHERE c.value=16
11 INNER JOIN k6l0c_alpha_userpoints AS p ON p.userid = c.user_id
12 INNER JOIN k6l0c_user_usergroup_map AS grp ON c.user_id = grp.user_id
13 WHERE grp.group_id = 2
14 GROUP BY c.value ) AS sub
15 INNER JOIN k6l0c_community_fields_values AS com ON com.value = sub.value
16 INNER JOIN k6l0c_alpha_userpoints AS pts ON pts.points = sub.max_pts AND pts.userid = com.id
17 INNER JOIN k6l0c_users AS usr ON usr.id = pts.userid
18 WHERE com.value!='' AND pts.points >0
19 ORDER BY pts.points DESC
ciao,
non vorrei sbagliare ma a me sembra che ci sono 2 where al rigo 10 e al rigo 13.
credo sia quello l'errore, il where deve andare dopo INNER JOIN che sta al rigo 12
facci sapere.
ciao