SQL更新具有不同列值条件的列值
我有一个带有下面列的SQL表。我想根据其他超级磁极列的值更新最终目标列。如果有超级磁极,则应使用superAdminrole value更新final -lole coluation,logrole列值else
Groupid OwnerGid SuperAdminGroupId groupRole ownerRole SuperAdminRole FInalRole
----- ---------- ---------------- --------- --------- -------------- ---------
17 20 3 Admin User SAdmin Sadmin
2 null null Admin Admin
I have a sql table with below columns .I want to update the finalRole column based on value from other Superadminrole column .If there is superadminrole, finalrole column should be updated with superadminrole value else with grouprole column value
Groupid OwnerGid SuperAdminGroupId groupRole ownerRole SuperAdminRole FInalRole
----- ---------- ---------------- --------- --------- -------------- ---------
17 20 3 Admin User SAdmin Sadmin
2 null null Admin Admin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
案例
表达式应如下:或者您可以使用
iif
逻辑表达式:Your
CASE
expression should be as below:or you may use
IIF
logical expression: