是否可以通过索引删除 Postgres 数组元素?(使用 Postgres 9.3。)
我在文档(http://www.postgresql.org/docs/9.3/static/functions-array.html)中没有看到任何相关内容,但也许我还缺少其他功能?
我想允许用户取消定期订阅。考虑到我拥有的其他基础设施,最简单的方法是recurring
为用户的最新约会(日期)设置字段 = 0。所以我只需要recurring
在匹配特定用户的最新约会的行中更新字段的值。
这是我尝试过的:
UPDATE appointments SET recurring = 0 WHERE id = 433 AND time = max(time);
ERROR: aggregate functions are not allowed in WHERE
LINE 1: ...ments set recurring = 0 where id = 433 and time = MAX(time);
Run Code Online (Sandbox Code Playgroud)
和
UPDATE appointments SET recurring = 0 WHERE id = 433 AND time = SELECT MAX(time) FROM appointments WHERE id = 433;
Run Code Online (Sandbox Code Playgroud)
这是约会表的相关部分:
Table "public.appointments"
Column | Type | Modifiers
------------------+-----------------------------+----------------------------------------------------------------
id | integer | …
Run Code Online (Sandbox Code Playgroud)