假设我有两张桌子:
USER
+------+------+-------------------+
| ID | NAME | CREATED_TIMESTAMP |
+------+------+-------------------+
| 1 | N1 | Null |
+------+------+-------------------+
| 2 | N2 | Null | <--------- acceptor of reference-value
+------+------+-------------------+ \
| ... | ... | ... | \
+------+------+-------------------+ \
\
REFERENCE_CREATED_TIMESTAMPS \
+-------------+----+-------------------+ these records match
| TABLE_NAME | ID |CREATED_TIMESTAMP | /
+-------------+----+-------------------+ /
| USER | 1 | 12.03.12 17:20:40 | /
+-------------+----+-------------------+ /
| USER | 2 | 14.03.12 10:12:54 | <--- reference-value
+-------------+----+-------------------+
| FOO_TABLE | 1 | 17.05.12 08:10:01 |
+-------------+----+-------------------+
| ... | ...| ... |
+-------------+----+-------------------+
现在我想填充 USER 表中的 CREATE_TIMESTAMP 列,从REFERENCE_CREATED_TIMESTAMPS
表中获取值,即对于 ID=2 的用户,我将使用CREATED_TIMESTAMP
from REFERENCE_CREATED_TIMESTAMPS
row whereTABLE_NAME=USER
和的值ID=2
。
对 USER 表的所有记录执行此操作的查询是什么?