本文介绍了SQL用于更新来自不同表的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我正在尝试更新缺少某些数据的表,但是更新语句有问题。
我有以下表格和数据:
客户表1:
客户ID:1234
客户名称:John
客户联系人:0189541145
订单表2:
CustomerId:空白
订单编号:12345
订单类型:纸
如何更新表格还有客户ID:
Hi
I am trying to update a table which is missing some data, but having problems with the update statement.
I have the following tables and data:
Customer table 1:
CustomerID: 1234
CustomerName: John
CustomerContact: 0189541145
Orders table 2:
CustomerId: blank
OrderNumber: 12345
OrderType: paper
how can i update the table to also have customer ID:
update Orders
set customerID = c.CustomerID
from Customer
where customerID = 12345
推荐答案
这篇关于SQL用于更新来自不同表的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!