【发布时间】:2013-03-26 01:55:40
【问题描述】:
我正在为 PostgreSQL (9.1) 使用 pgadmin,我有这个查询需要很长时间才能运行
update tableA a
set owner1_surname = (select owner_surname from owners_distinct b where a.owner1= b.owner),
owner1_othername = (select owner_othername from owners_distinct b where a.owner1= b.owner),
owner2_surname = (select owner_surname from owners_distinct b where a.owner2= b.owner),
owner2_othername = (select owner_othername from owners_distinct b where a.owner2= b.owner),
owner3_surname = (select owner_surname from owners_distinct b where a.owner3= b.owner),
owner3_othername = (select owner_othername from owners_distinct b where a.owner3= b.owner)
不必一次又一次地从owners_distinct table 检索值,是否可以使用SELECT 检索列owner、owner_surname 和owner_othername,然后在@ 上执行UPDATE 987654328@的列基于检查?
【问题讨论】:
标签: sql postgresql sql-update postgresql-9.1