【发布时间】:2021-01-29 00:35:35
【问题描述】:
我正在构建一个简单的 sql 查询,但我无法理解这个查询。 这是表格的布局:
挑战:我想从该表中获取所有内容,前提是存在阈值不为 20 的条目(按 id_order)(在这种情况下,应动态显示 ID 18)。
我在想:
SELECT * FROM `cancelorders_history` WHERE threshold != 20 GROUP BY `id_order`
虽然这会引发以下错误(并且我不确定查询是否与我正在寻找的逻辑匹配,如上所述):
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'exampletable.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
我不能使用:
SELECT * FROM `cancelorders_history` WHERE threshold != 20
因为给我的 ID 都是 13、18、19。
解决这个问题的首选方法是什么?
【问题讨论】: