Query funktioniert - und funktioniert nicht
hörbiger
- datenbank
Hello,
ich habe eine Abfrage:
select id_table, count(*) from table WHERE vote = 1 GROUP BY id_table ORDER by count(*) DESC LIMIT 20
In der Tabelle gibts Felder id_tabelle und vote. Vote ist entweder -1 oder 1.
Lokal funktionierts (5.0.21) Remote funktionierts nicht(4.1.12). Auf dem Remote bekomme ich: Invalid use of group function.
Group Function. Soso. Hat jemand einen Plan, wie ich die Query umschreibe, dass es auch auf einem vierer mySQL funktioniert?
Gruß
Hörbiger
Hello,
select id_table, count(*) from table WHERE vote = 1 GROUP BY id_table ORDER by count(*) DESC LIMIT 20
Group Function. Soso. Hat jemand einen Plan, wie ich die Query umschreibe, dass es auch auf einem vierer mySQL funktioniert?
ich hab nur ne Vermutung, und zwar, dass er sich u.U. an dem COUNT(*) im ORDER BY stößt, weiß ich aber nicht genau - versuch es mal mit einer benannten Spalte.
SELECT id_table, COUNT(*) AS num_votes
FROM table
WHERE vote=1
GROUP BY id_table
ORDER BY num_votes DESC
LIMIT 20
MfG
Rouven
Held! klar funktionierts so!
Gracias!
SELECT id_table, COUNT(*) AS num_votes
FROM table
WHERE vote=1
GROUP BY id_table
ORDER BY num_votes DESC
LIMIT 20