Jump to content
  • Advertisement
Sign in to follow this  
BeanDog

[web] [MySQL4] Doing a "where" after a "group by"

This topic is 4374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a query that looks something like this: select person.*, sum(item.amount) as Total from person inner join item on item.personid = person.personid group by person.personid This sums up the total number of items for each person and returns it alongside the person record. What I want to do is something like this: select person.*, sum(item.amount) as Total from person inner join item on item.personid = person.personid group by person.personid where Total > 100 The problem is, I can't filter by aggregate fields. I'm using MySQL 4, so I can't use a subquery to get the job done. I have to do this in MySQL rather than manually in my PHP because I intend to do paging with "limit". How would I get this done?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!