当前位置: 代码迷 >> Sql Server >> 关于连表更新数据的有关问题
  详细解决方案

关于连表更新数据的有关问题

热度:70   发布时间:2016-04-24 09:23:53.0
求助关于连表更新数据的问题
有2张表

dbo.ShipH
有以下的列
Invoice  Customer  

dbo.ShipD
有以下的列
Invoice  InvoiceBr  ST  InvoiceDate

dbo.ShipH的 Invoice和dbo.ShipD的Invoice是一样的
 现在知道  顾客id  和时间区间 FM 和TO

想将 Customer= 顾客id   InvoiceDate> FM  InvoiceDate<To  的 ST改为001

想了好久不好写。谢谢
------解决思路----------------------

update a
 set a.ST='001'
 from dbo.ShipD a
 inner join dbo.ShipH b on a.Invoice=b.Invoice
 where b.Customer=[顾客id] and a.InvoiceDate>[FM] and a.InvoiceDate<[To]
  相关解决方案