mysql5.7 groupエラーERROR 1055(42000):Expression#1
1433 ワード
ubuntu16.04 apache2.4 php7.0 mysql5.7
出力結果
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'orderid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
解決策
1.sql_の表示モデルパラメータ
に見える
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
そして
更新
mysqlを終了
mysqlプロファイルの編集
この行に加わる
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
mysqlを再起動
完了します.
注意:service mysql reloadは役に立たない.
$order_goods=db('order_goods')->where('orderid','in',$_orderid_arr)->group('orderid')->having('id>0')->select();
echo db('order_goods')->getLastSql();exit;
出力結果
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'orderid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
解決策
1.sql_の表示モデルパラメータ
mysql -u root -p
SELECT @@GLOBAL.sql_mode;
に見える
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
そして
set sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
更新
flush privileges;
mysqlを終了
exit;
mysqlプロファイルの編集
vi /etc/mysql/mysql.conf.d/mysql.cnf
この行に加わる
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
mysqlを再起動
service mysql restart
完了します.
注意:service mysql reloadは役に立たない.