MySQL ORDER by and GROUP by

Source: Internet
Author: User

Today, the MYSQ version of the site was updated to the latest version of 5.7 An error statement occurred while querying the statement:

ORDER by clause isn't in GROUP by clause and contains nonaggregated column ' G2yx_yy.u.login_time ' which are not functional Ly dependent on columns in GROUP by clause; This was incompatible with sql_mode=only_full_group_by

The error in this statement is that the order BY statement does not depend on the group by statement. The following is the error statement I wrote earlier

$myGameData = Db::name (' user_played ')
->alias (' u ')
->join (' Game g ', ' g.id = u.game_id ')
->join (' Area A ', ' a.id = u.area_id and a.game_id = u.game_id ')
->field ($condition [' field '])
->where ($condition [' where '])
->group (' u.area_id ')
->order (' U.login_time DESC ')
->select ();

The above also said why the error after the SQL statement into
$myGameData = Db::name (' user_played ')
->alias (' u ')
->join (' Game g ', ' g.id = u.game_id ')
->join (' Area A ', ' a.id = u.area_id and a.game_id = u.game_id ')
->field ($condition [' field '])
->where ($condition [' where '])
->group (' U.area_id,u.login_time ')
->order (' U.login_time DESC ')
->select ();

You'll be able to solve the problem.



MySQL ORDER by and GROUP by

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.