首页 > 解决方案 > SQL 查询 GROUP BY 在通过 Google Chome 访问的 w3 学校网站上未按预期工作,通过 Firefox 按预期工作

问题描述

我尝试从 w3schools.com 上的 ubuntu 18.04 机器上运行以下查询“自己尝试”SQL 控制台从两个不同的浏览器 -
1. Google Chrome(版本 81.0.4044.122(官方构建)(64 位))
2. Firefox(版本 75.0(64 位))。

SELECT City, Country

FROM Customers

GROUP BY Country;

此查询在运行时不应该工作,在 firefox 上也观察到了同样的情况。

Result on w3schools in Firefox  
Error in SQL:
You tried to execute a query that does not include the specified expression 'City' as part of an aggregate function.

但是,当在 Google Chrome 中执行相同的查询时,会得到以下结果。

Number of Records: 21

City                Country
Buenos Aires        Argentina
Graz                Austria
Bruxelles           Belgium
São Paulo           Brazil
Tsawassen           Canada
København           Denmark
Oulu                Finland
Strasbourg          France
Berlin              Germany
Cork                Ireland
Torino              Italy
México D.F.         Mexico
Stavern             Norway
Walla               Poland
Lisboa              Portugal
Madrid              Spain
Luleå               Sweden
Bern                Switzerland
London              UK
Eugene              USA
Caracas             Venezuela

当通过 Google Chrome 在 w3school.com 上运行查询时,我不明白在后台发生了什么。

自己试试https ://www.w3schools.com/sql/trysql.asp?filename=trysql_select_groupby

标签: sqlgoogle-chromeubuntufirefoxw3c

解决方案


w3schools 的 JavaScript 实际上是对 SQLite 数据库执行这些操作。当您加载页面时,脚本w3Database.js正在初始化数据库。FireFox 中 SQLite 的实现与 Chrome 中的实现略有不同。这就是为什么你会看到这种差异。

随时报告 Chrome 的错误。


推荐阅读