【发布时间】:2017-01-16 15:32:37
【问题描述】:
我有一个像这样的简单表格:
id grouped type_error
-- ------- ------------------
1 1-0 TL
2 1-0 TL
3 1-0 TL
4 1-1 TL
5 1-2 TL
6 1-2 TL
7 1-3 TL
8 1-3 TL
9 1-3 TL
10 1-3 TL
我只想将表格更新为这样:
id grouped type_error
-- ------- ------------------
1 1-0 FN
2 1-0 FN
3 1-0 FN
4 1-1 TL
5 1-2 TL
6 1-2 TL
7 1-3 FN
8 1-3 FN
9 1-3 FN
10 1-3 FN
我想更新分组计数最小 3 和最大 5 的位置:
我只是有这样的查询:
update errorlog set type_error = 'FN' where id in
(select group_concat(id) as ids from errorlog where ids > 2 group by grouped)
但是,它不起作用。我得到了错误
“where 子句”中的未知列“ids”
【问题讨论】:
-
不理解您的示例结果。
grouped count is min 3 and max 5但在 ID 为 1 到 3 的行中,分组字段为 1-0 -
如果您对计数感兴趣,为什么要包含 group_concat
-
你能把mysql的错误贴出来吗?
-
@JochenSchultz 'where 子句'中的未知列'ids'。
-
@Alfabravo,如果我的英语不好,请多多关照。我需要使用 group by grouped coulumn 更新 count(id) 在 3 和 4 之间的位置。
标签: mysql group-by sql-update max min