重写查询以防止only_full_group_by错误

时间:2016-05-13 10:16:11

标签: mysql sql group-by mysql-5.7

我有以下查询:

 private void cnvDrop_DragOver(object sender, DragEventArgs e)
 {           
    e.DragUIOverride.IsGlyphVisible = false;
 }

现在我升级了MysQL并激活了SELECT f.flight_number, f.flight_date, f.airport, a.iata, a.iso3166 AS airport_country_code, air.icao FROM flights_database f LEFT JOIN airlines air ON air.name = f.airline JOIN airports a ON f.airport = a.airportNameClean WHERE f.flight_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_ADD(CURDATE() , INTERVAL 1 DAY) GROUP by f.flight_date, f.airport, f.flight_number, a.iata ORDER by f.airport, f.flight_number 。 此查询不再以此形式运行:

only_full_group_by setting

当然我可以禁用此设置,但我确实理解此设置是出于某种原因而引入的。简单地将Expression #6 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'air.ICAO' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 添加到icao子句会引入不同的结果。

如何在启用此设置的情况下重写此查询以实现相同的行为?

1 个答案:

答案 0 :(得分:1)

你不能只做Int吗?

return declare('myPlugin.Layout', [NavigatorMainLayout], {

    browseFeatureId: 'MyBrowseFeature',

    setFeatures: function(selectedFeatures, defaultFeature, defaultSecondaryPlugin) {
    var browseIndex = array.findIndex(selectedFeatures, function (feature) {
        return feature.id === this.browseFeatureId;
    }, this);

    var original = this.getInherited(arguments);
    var args = arguments;

    var repositoryId = "REPOSITORYID";

    var config = ecm.model.Request.invokePluginServiceSynchronous("MyPlugin", "GetPluginConfigurationService", { requestParams: {} });

    ....
},