两表更新:根据条件从一个表里面查询出符合条件的结果更新另一个表

 表一 App

 表二 Screenshot

下面语句的意思: 根据表Screenshot里面的外键AppId=App.Id 把 ScreenshotUrl值赋给App 表的Url

update App set Url=(select Screenshot.ScreenshotUrl from Screenshot where AppId=App.Id and Screenshot.No=0)

原文地址:https://www.cnblogs.com/hubcarl/p/1711319.html