0
鑑於PostgreSQL數據庫下面兩個表...如何根據第二個表中的值更新一個表中的列?
表observation
:
+---------------+---------+
| observationid | deleted |
+---------------+---------+
| 1 | F |
| 2 | F |
| 3 | F |
+---------------+---------+
表numericvalue
:
+---------------+-------+
| observationid | value |
+---------------+-------+
| 1 | 999 |
| 2 | 5 |
| 3 | 999 |
+---------------+-------+
我想deleted
列的值設置爲'T'
只要numericvalue
中的關聯行包含value
等於的所有行在。
的SELECT
查詢看起來是這樣的:
SELECT *
FROM observation o
INNER JOIN numericvalue n
ON o.observationid = n.observationid
AND n.value = 999;