假设我有一个包含以下内容的表格:
mysql> select * from test;
+----+------+
| id | val |
+----+------+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 2 |
| 6 | 2 |
| 7 | 2 |
| 8 | 2 |
+----+------+
8 rows in set (0.00 sec)
mysql>
现在我使用group by
子句运行错误的 SQL 查询,并且在列上没有任何聚合id
并得到错误的结果:
mysql> select id, val from test group by val;
+----+------+
| id | val |
+----+------+
| 1 | 1 |
| 5 | 2 |
+----+------+
2 rows in set (0.00 sec)
mysql>
mysql 客户端或其他工具能否验证此查询并在group by
不聚合的情况下使用时发出错误或警告?