GROUP approach is also consistent operating one of the methods

GROUP consistent operation method is also one of the methods typically used in conjunction with aggregate functions, grouping result set according to one or more columns.

group a single parameter, and only string.

For example, we all query results are grouped according to statistics user id:

  1. $this->field('username,max(score)')->group('user_id')->select();

Marble measurement platform

Generated SQL statement is:

  1. SELECT username,max(score) FROM think_score GROUP BY user_id

Also supports a plurality of packet fields, for example:

  1. $this->field('username,max(score)')->group('user_id,test_time')->select();

Generated SQL statement is:

  1. SELECT username,max(score) FROM think_score GROUP BY user_id,test_time
 

Guess you like

Origin www.cnblogs.com/furuihua/p/11804326.html