求一个功能的sql语句实现

SUMI_SUMI 2018-08-28 06:38:17
我在Sqlite里面有表为 T_Table
表数据如下:
stra|strb|strc|strd|
87 | |1 |0 |
88 |87 |0 |0 |
89 |90 |0 |0 |
90 |87 |2 |0 |
91 |90 |0 |0 |
92 |90 |0 |0 |
我想通过sql语句,实现遍历后strc =0的行,strc的值更新为其它行stra的值等于该行strb的值对应的strc的值,如下

stra|strb|strc|strd|
87 | |1 |0 |
88 |87 |1 |0 |
89 |90 |2 |0 |
90 | |2 |0 |
91 |90 |2 |0 |
92 |87 |1 |0 |
请问通过纯sql语句如何实现?
...全文
126 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
SUMI_SUMI 2018-08-28
  • 打赏
  • 举报
回复
引用 1 楼 SUMI_SUMI 的回复:
update T_Tableset strc=(select strcfrom T_Tableset b where b.stra=du.strb) where strc=0
结贴 想复杂了 傻了.....自己搞定


update T_Tableset strc=(select strcfrom T_Tableset b where b.stra=T_Tableset .strb) where strc=0
SUMI_SUMI 2018-08-28
  • 打赏
  • 举报
回复
update T_Tableset strc=(select strcfrom T_Tableset b where b.stra=du.strb) where strc=0
结贴 想复杂了 傻了.....自己搞定

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧