在pgsql中的语法方式:
update cg_jjzz_gqfp
set lhze=b.sjlhje, fpze=b.sjlhje, mggz=b.mggz, fpgfs = b.fpgfs, jtgzb=b.jtgzb, jtggfs = b.jtggfs, grgzb=b.grgzb, grggfs=b.grggfs
from (select sjlhje, sjlhje fpze, 1 mggz, sjlhje / 1 fpgfs, 0.5 as jtgzb, sjlhje * 0.5 as jtggfs, 0.5 as grgzb, sjlhje * 0.5 as grggfs, area_id from cg_zclh where area_id = '469007102200' ORDER BY djnd desc limit 1) b
where cg_jjzz_gqfp.area_id = '469007102200'
语句执行成功:
错误案例1:下面是mysql的一种形式,再pgsql中会报错
update cg_jjzz_gqfp a,(select sjlhje, sjlhje, 1 mggz, sjlhje / 1, 0.5 as jtgzb, sjlhje * 0.5 as jtggfs, 0.5 as grgzb, sjlhje * 0.5 as grggfs, area_id from cg_zclh where area_id = '12345' ORDER BY djnd desc limit 1) b
set a.lhze=b.sjlhje, a.fpze=b.sjlhje, a.mggz=b.mggz, a.jtgzb=b.jtgzb, a.grgzb=b.grgzb, a.grggfs=b.grggfs,
where area_id='12345'
报错: