亲们,这个sql要怎么写啊?

xlh0053 2013-05-07 05:13:52
表a lqe01 lqe02
10001
10002
10003
10004
10005
.
.
.
10010

表b lpz03 lpz04 lpz05
10001 10002 100
10003 10005 800
10006 10010 300

我要怎么根据表B的lpz05来更新表A的lqe02字段,结果如下:
表a lqe01 lqe02
10001 100
10002 100
10003 800
10004 800
10005 800
10006 300
10007 300
10008 300
10009 300
10010 300
...全文
215 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
oracle的写法,你要到oracle版块下面去问啊,问错地方还这么横么? update A set lqe02 =(select lpz05 from B where B.id=A.id) where exists (select 1 from B where B.id= A.id)
xlh0053 2013-05-08
  • 打赏
  • 举报
回复
oracle的写法啊,没人用oracle吗
daiyueqiang2045 2013-05-07
  • 打赏
  • 举报
回复
update A
set lqe02 = B.lpz05
from B where a.lqe01>=B.lqe03 OR a.lqe01<=B.lqe04 
MrYangkang 2013-05-07
  • 打赏
  • 举报
回复


update A
set lqe02 = B.lpz05
from B where a.lqe01 =B.lqe03 OR a.lqe01 =B.lqe04 
函麻 2013-05-07
  • 打赏
  • 举报
回复
update a set a.lqe02=b.lpz05 from a,b where a.lqe01 =b.lqe03
xlh0053 2013-05-07
  • 打赏
  • 举报
回复
补充一下,我的是oracle数据库
MrYangkang 2013-05-07
  • 打赏
  • 举报
回复
update A set lqe02 = B.lpz05 from B where a.lqe01 =B.lqe03

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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