SQL update table1 with table1?
table1:
id_x
field
table2:
id
id_x
type_id;
update table1 set field=2 where type_id = 4;
我该怎么做(PSQL)?
答案 0 :(得分:2)
这应该可以帮到你,假设table2中的id_x
是table1中id_x
的外键引用 -
update table1 set field=2
where id_x in
(
select id_x from table2 where type_id = 4
)