There is a base structure: enter image description here

First I select all users and groups that they follow from the User table. Next, you need to get the number of people to each group, these data need to be pulled from the Groups table (link across the group field), now it would be nice to tighten the balance of the user of each balance here id is the uid in User.

The query works:

SELECT t1.uid, t1.group, t2.people FROM User AS t1, Groups AS t2 WHERE t1.group = t2.group 

But in the Groups table there are several entries and you need to choose where people is the maximum value. Change the request t2.people to t2.MAX (people) and everything stops working. Or at least how can I put LIMIT out of Groups, only 1 record is selected?

  • Check commas. - D-side
  • @ D-side yes thanks, there was a mistake - RoboNoob
  • 2
    If there is time - please issue a response so that users who come from search engines can see it and compare it with their situation - etki

1 answer 1

t2.MAX (people) replace with MAX (t2.people)