Today, I was told to write a service that was designed to serve each member in accordance with the highest division of the competition in each of the classes, so there are two technical requirements
1 Find the Champions team for each class
2 increase the score of a group of people
From "1", find out the scoring champion team in each class n group, then divide the team score into n parts according to the number of team members, and update the group's score with the method "2".
On the query code!
1 There may be a better way, I reference this article on the Internet,
Http://www.jb51.net/article/31590.htm
Select the Inner JOIN in Method 4, of course, there is a class in two groups of split children and fractions divided by the number of people are not integers, this is not considered in the program logic processing, only to implement the query to achieve the original information.
1 -- query each class's champions team 2 3 from t_mfg_classgamegroup a INNER JOIN (4 56 ona.f_classid = b.f_classid and A.f_score = 7
Query results
2 data is simulated.
--ten where F_uid in (SELECT f_uid from T_mfg_usergroup WHERE2)
With these two tool statements, you can implement the update
Mysql packet Query Highest score