2013-05-02 44 views
0

我正在寻找在PostgreSQL的优化的方法,这样做:我怎么能在PostgreSQL上指定一个多字段功能结果更新

update table1 
set (a,b)=(somecomplexfunction(table1.something),2*somecomplexfunction(table1.something)) 
where ... 

这算somecomplexfunction(table1.something)两次,我d喜欢做这样的事情:

update table1 set (a,b)=somecomplexvectorfunction(table1.something) where ... 

但更新语法不支持多个字段功能。有任何想法吗?

回答

1
update table1 
set 
    a = somecomplexfunction(table1.something), 
    b = a * 2 
where ... 
+0

是不是“a”旧时“我”加倍了? – 2013-05-22 16:03:12