
请教一个sql中update和联合查询的问题,急急急~~
我现在有table_v,table_p两张表,我想把table_v.xh中的‘abc’update成‘xx’,条件是table_v.wid=table_p.gid,怎么实...
我现在有table_v,table_p两张表,我想把table_v.xh中的‘abc’ update 成 ‘xx’,条件是 table_v.wid=table_p.gid ,怎么实现,我写的怎么都不对,麻烦给指点一下,谢谢,在线等答案~~~
update table_v set xh='xx' where xh='abc' ,条件是 table_v.wid=table_p.gid ,怎么加条件?哎,怎么木有人~~~~~~~~~~~ 展开
update table_v set xh='xx' where xh='abc' ,条件是 table_v.wid=table_p.gid ,怎么加条件?哎,怎么木有人~~~~~~~~~~~ 展开
展开全部
这样试试,如果还不行,说明还需要加条件,被你忽略了。
update table_v set xh='xx' where xh='abc' and wid in (select gid from table_p)
如果在table_p中还有限制条件呢?你还需要加上
update table_v set xh='xx' where xh='abc' and wid in (select gid from table_p)
如果在table_p中还有限制条件呢?你还需要加上
追问
按照您这种方法写,好像'and' 报错。其他条件我是加上了的
update table_v set xh='xx' where xh='abc' and wid in (select p.gid from table_p p where (其他条件) ) 我是这么写的
追答
那你就把两个条件都加上括号。
update table_v set xh='xx' where (xh='abc') and (wid in (select p.gid from table_p p where (其他条件)))
你其它条件中有and 吗?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?

2025-04-08 广告
Stata系列软件全国授权代理——北京友万。北京友万信息科技有限公司,总部设在北京市昌平科技园区,是一家专注于引进国内外软硬件产品的中关村高新技术企业。公司拥有多项自主研发的数据平台,依托自身经验丰富的技术团队资源,为不同领域的客户提供全面...
点击进入详情页
本回答由友万科技提供
展开全部
你这个是连表update你这样写
update table_v set table_v.xh=‘xx’ from table_v left join table_p on table_v.wid=table_p.gid
where table_v.xh=‘abc’
update table_v set table_v.xh=‘xx’ from table_v left join table_p on table_v.wid=table_p.gid
where table_v.xh=‘abc’
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
update table_v v set v.xh='xx'
where exists (select 1 from table_p p where p.gid = v.wid)
and v.xh='abc'
where exists (select 1 from table_p p where p.gid = v.wid)
and v.xh='abc'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
update table_v
set xh='xx'
inner join table_p
on table_v.xh=table_p.xh
where table_v.xh='abc'
set xh='xx'
inner join table_p
on table_v.xh=table_p.xh
where table_v.xh='abc'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用in吧 再说了 条件也不一样啊。
追问
我这样写的 update table_v set xh='xx' where xh in (select v.xh *from table_v v,table_p p where v.wid=p.gid ) and xh='abc' ,可是这样就全部吧‘abc’改成‘xx’了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询