小编Gri*_*gor的帖子

有一个名为...的列不能从查询子查询的这部分引用

 WITH upt as (
 UPDATE backend."orders" SET "statusId" = 5
 WHERE "userId" IN (177962,88265) and "statusId" IN (0,1,2,3,4) RETURNING *
)
 INSERT INTO __test_result(orderid) VALUES ((SELECT orderid FROM upt))
Run Code Online (Sandbox Code Playgroud)

需要更新和记录数据,得到这个错误

ERROR: column "orderid" does not exist Hint: There is a column named 
"orderid" in table "__test_result", but it cannot be referenced from this part of the query.
Run Code Online (Sandbox Code Playgroud)

如何在表中插入所有“upt”行?它必须看起来

"upt.orderid","jsonb for that orderid"
Run Code Online (Sandbox Code Playgroud)

对于每个订单 jsonb 必须从具有相同 orderid 的“upt”列创建

sql postgresql sql-insert

6
推荐指数
1
解决办法
9910
查看次数

更新 jsonb postgres 中的时间戳

如何将 jsonb 中的时间戳更新为函数 now() 的值?

我尝试像这样做smt

    UPDATE test
    SET column = jsonb_set(column,'{time}',to_char(now(),'some date format'),true)
Run Code Online (Sandbox Code Playgroud)

我遇到了类似的错误

    'jsonb_set(json,unknown,text,bool) is not available' 
Run Code Online (Sandbox Code Playgroud)

我认为错误的原因是 now() 的值不是单引号,因为这个查询正在工作

    UPDATE test
    SET column = jsonb_set(column,'{time}','date with the same date format ',true)
Run Code Online (Sandbox Code Playgroud)

有什么解决办法吗?

postgresql jsonb

5
推荐指数
1
解决办法
4699
查看次数

PostgreSQL 格式时间戳,格式为 h:mm am/pm

想要获取格式为“h:mm a”的时间戳/文本(来自时刻js)

例如SELECT to_char(current_timestamp, 'HH12:MI am')

这会给出08:13 am这个结果,但我需要8:13 am

sql postgresql select timestamp date

0
推荐指数
1
解决办法
3536
查看次数

标签 统计

postgresql ×3

sql ×2

date ×1

jsonb ×1

select ×1

sql-insert ×1

timestamp ×1