0
带table1中条件的SQL更新table1?具有table2中的条件的SQL更新table1?
table1:
id_x
field
table2:
id
id_x
type_id;
update table1 set field=2 where type_id = 4;
我该怎么做(PSQL)?
带table1中条件的SQL更新table1?具有table2中的条件的SQL更新table1?
table1:
id_x
field
table2:
id
id_x
type_id;
update table1 set field=2 where type_id = 4;
我该怎么做(PSQL)?
这应该做的伎俩对你来说,在表2假设id_x
是在表1的id_x
外键参考 -
update table1 set field=2
where id_x in
(
select id_x from table2 where type_id = 4
)
萨钦Shanbhag,非常感谢。 – kn3l 2011-03-31 09:23:16
是我使用PSQL数据库 – kn3l 2011-03-31 09:13:25