0

鉴于 PostgreSQL 数据库中的以下两个表...

observation

+---------------+---------+
| observationid | deleted | 
+---------------+---------+
|      1        |    F    |
|      2        |    F    |
|      3        |    F    |
+---------------+---------+

numericvalue

+---------------+-------+
| observationid | value | 
+---------------+-------+
|       1       |  999  |
|       2       |   5   |
|       3       |  999  |
+---------------+-------+

每当关联行中包含等于时,我想将列的值设置deleted'T'在所有行中。observationnumericvaluevalue999

SELECT查询如下所示:

SELECT *
FROM observation o
INNER JOIN numericvalue n
ON o.observationid = n.observationid
AND n.value = 999;
4

2 回答 2

1
UPDATE observation ob
SET deleted = 'T'
FROM numericvalue nv
WHERE nv.value = 999
AND nv.observationid = ob.observationid;
于 2015-11-10T23:30:44.697 回答
0
UPDATE observation
SET deleted = 'T'
WHERE observationid IN (SELECT observationid FROM numericvalue WHERE value=999)
于 2015-11-11T04:34:02.593 回答