求sql 语句 ---

yiyi0518 2009-11-04 01:54:59


表 A (
cable_no varchar(10)
is_valid char(1) )
表 B (
cable_no varchar(10)


现在要将cable_no 在表A中存在, 表 B 中不存在的 那些记录 is_valid 设为‘0’

求sql 语句
...全文
71 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlqyizhizailushang 2009-11-04
  • 打赏
  • 举报
回复
update A set flag=0 from A t where not exists(select 1 from B where id=t.id)
Rotel-刘志东 2009-11-04
  • 打赏
  • 举报
回复
update B set is_valid='0'where is_valid in(select is_valid from A a inner join B b on a.cable_no=b.cable_no
and b.is_valid=null
bancxc 2009-11-04
  • 打赏
  • 举报
回复

update B set Is_Valid=0
from B
inner join A on A.cable_no=B.cable_no
jiangshun 2009-11-04
  • 打赏
  • 举报
回复
update A set is_valid='0' where cable_no not in(select cable_no from B)
jiangshun 2009-11-04
  • 打赏
  • 举报
回复
update A set is_valid='1' where cable_no not in(select cable_no from B)
  • 打赏
  • 举报
回复
update a
set is_valid=0
from a left join b on a.cable_no=b.cable_no
where b.cable_no is null
xiequan2 2009-11-04
  • 打赏
  • 举报
回复
update a set is_valid=0 where cable_no not in(select cable_no from b)

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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