【发布时间】:2019-07-01 09:48:18
【问题描述】:
有两个表表 A 和表 B。它们包含相同的列 cost 和 item。表 B 包含项目列表及其相应的成本,而表 A 仅包含项目列表。
现在我们需要检查表 A 的项目,如果它们存在于表 B 中,则应将相应的项目成本分配给表 A 中的项目成本。
谁能帮我写一个查询。
考虑如下所示的表格:
表 A:
item cost
-------------
pen null
book null
watch null
表 B:
item cost
-------------
watch 1000
book 50
预期输出
Table A:
item cost
pen 0
book 50
watch 1000
【问题讨论】:
标签: sql postgresql sql-update dml