语法和PostreSQL一致,和Oracle的区别有点大。Oracle如果Update有Select的话是直接在Update后面的子查询里面的
语法
UPDATE [ONLY] table [[AS] alias]
SET {column = {expression | DEFAULT} |
(column [, ...]) = ({expression | DEFAULT} [, ...])} [, ...]
[FROM fromlist]
[WHERE condition | WHERE CURRENT OF cursor_name ]
实例
update fs.test t
set channelprice = t1.channelprice,
channelname = t1.channelname,
provider = t1.provider,
provinceid = t1.provinceid,
spcode = t1.spcode,
from (select * from def.test2 ) t1
where t.sp_pay_id = t1.utmid
and t.create_time >= '2016-05-01'::date
and t.create_time < '2016-06-08'::date
and t.real_type = '961'
注意事项
对于set列中左边的列不能使用t.这种别名方式,只能使用columen名称
本文来源:https://blog.csdn.net/Team77/article/details/51611937