【发布时间】:2018-04-19 08:38:33
【问题描述】:
我有一种情况,我有一个表 (tbl1),并在其中添加了一个当前全为空的列。我想使用更新语句来填充此列,其中包含连接在一起的 3 个其他列的值。这些其他列中的 1 个可以使用,但其他两个具有需要与另一个表 (tbl2) 连接的值,以根据下面的表示例从 tbl2 查找单个字符关联代码。 tbl2 中的 CostType 和 RefType 存在于 tbl1 中,但我想将 CostCode 和 RefCode 带到 tbl1 的空列中。我还展示了我使用 Advantage SQL Architect 尝试过的内容。但看不到让它工作。
update tbl1
set emptycolumn=tbl.column1+tbl2.costcode+tbl2.refcode
from tbl1 left join tbl2 on (tbl1.costtype=tbl2.costtype)
left join tbl2 on (tbl1.reftype=tbl2.reftype)
CostCode CostType RefCode RefType
A Apportioned Cost E EmployeeID
J Funding Adjustment I Invoice
G Grant G Grant Recipient
M Grant Management L LearnRefNumber
O Other Costs N CompanyName
E Staff Expenses O Other
F Staff Full Time C Authorised Claims
P Staff Part Time A Audit Adjustment
U Unit Cost
D Unit Cost Deduction
S Start Payment
C Completion Payment
【问题讨论】:
-
它是如何“不工作”的?这是相当模糊的。
标签: sql advantage-database-server