大家好,我试图有效地更新postgres中的最新记录都无济于事。 下面显示的示例
created table instructions
{
uuid uuid,
type text,
status text,
owner text,
created_at timestamp
}
我尝试了类似的方法,但是没有运气
update table instructions
set status = status
where uuid = uuid
order by created_at desc
limit 1;
但这似乎不起作用。有什么建议?
答案 0 :(得分:0)
要使用更新限制,您可以做的一件事是使用CTE: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=2cd45704599069a963db9046c8b3d26d
this post在不同的堆栈交换上解释得很好。