Jump to content

GROUP BY and ORDER BY together


biohazardep

Recommended Posts

I'm trying to run the next query:

SELECT username, COUNT(item_id) 
FROM (phpbb_lms_items LEFT JOIN phpbb_lms_mochilas ON item_moch=moch_id)
LEFT JOIN phpbb_users ON moch_dueno=user_id
GROUP BY moch_dueno
ORDER BY COUNT(item_id) DESC

 

It works as i want it to in my windows server, but not in my linux server. In the linux box i get the message:

"SQL Error : 1111 Invalid use of group function"

 

The windows server has the following versions:

Apache Web Server Version 2.2.3

PHP Version 5.1.6

MySQL Database Version 5.0.24a

 

The linux one has:

Apache Web Server Version 1.3.33

PHP Version 4.3.11

MySQL Database Version 5.0.18

 

Can anyone help me get it to work in the linux server please?

 

Note: The linux box is from paid hosting, so i can't do much about what versions or features it has. My windows server is only for testing and development before i move my code to the live server (the linux one).

Link to comment
https://forums.phpfreaks.com/topic/54624-group-by-and-order-by-together/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.