【发布时间】:2016-01-27 11:33:03
【问题描述】:
我有两个表 tbLicence 和 tbCompanyAgent,如屏幕截图所示
在 tbCompanyAgent 中存在一些与 tbLicence 中相同的常见列值,例如 LicenseNumber、LicenseIssueDate 和 LicenseExpirationDate。在一些复杂的 sql 查询和业务需求之后,将 tbLicence 中的 StateIssuedLicenseNumber、StateIssuedLicenseIssueDate 和 StatedIssuedLicenseExpirationDate 列以及 LicenceNumber、DateIssued 和 ExpirationDate 列合并到 tbCompanyAgent 中的单个列 LicenseNumber、LicenseIssueDate 和 LicenseExpirationDate。
StateIssuedLicenseNumber、StateIssuedLicenseIssueDate 和 StatedIssuedLicenseExpirationDate 中的值对于由 Group Id Column LicenceType 标识的同一组记录也是相同的。
实际上,所有许可证都有一个常驻条目,存储在 StateIssuedLicenseNumber、StateIssuedLicenseIssueDate 和 StatedIssuedLicenseExpirationDate 列,由值为 1 的 Resident 列标识。
非居民许可证存储在 LicenceNumber、DateIssued 和 ExpirationDate 中,值为 0。
我的问题是,如果用户尝试在 tbLicence 中进行一些更新,这些更新应该反映在 tbCompanyAgent 上。我将如何编写查询。请帮忙!!!
【问题讨论】:
-
你可以使用更新加入。
-
能否提供查询...
标签: sql sql-server sql-server-2008