【发布时间】:2019-05-28 15:16:55
【问题描述】:
如果相关表中存在与 iid 匹配的行,我正在尝试更新 itemTable 上的列。
itemMeta 是 NoSQL 样式表,表上每个项目都有重复的 iids,itemTable 是关系表。
update itemTable it
set hasAttributes = (select
case when select count(1) from itemMeta where (im.iid = it.iid)
then 'Y'
else 'N' end)
from itemMeta im
where (im.iid = it.iid)
如果itemMeta 上存在与iid 匹配的行,如何将itemTable 上的列设置为Y?
【问题讨论】:
-
用您正在使用的数据库标记您的问题。您的查询有什么问题?您想将值更新为什么?
-
使用 SQL Server 标记更新。
标签: sql sql-server sql-update case exists