一条SQL语句的问题

jeffrywang 2003-10-14 10:37:05
我想在查询分析器中从表A中取字段X1在某一时间段(X2)内的值
赋予表B中的字段X3,两个表通过字段X4关联的(即两个都含有X4这个字段,并且值是相等的),这个SQL语句怎么写?
请指教!!!多谢!!!
...全文
41 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeffrywang 2003-10-14
  • 打赏
  • 举报
回复
加10分相送,非常感谢
Dennis618 2003-10-14
  • 打赏
  • 举报
回复
create table #t1 (id int,x int)
create table #t2 (id int,y int)
insert into #t1 values(1,5)
insert into #t1 values(2,7)
insert into #t1 values(3,11)
insert into #t1 values(4,18)

insert into #t2 values(2,0)
insert into #t2 values(3,0)
insert into #t2 values(4,0)

update #t2 set y=x from #t1 a,#t2 b where a.id=b.id
select * from #t2
drop table #t1
drop table #t2
pengdali 2003-10-14
  • 打赏
  • 举报
回复
update 表b set x3=a.x1 from 表A a where a.x4=表b.x4 and a.x1 在某一时间段(X2)
zjcxc 元老 2003-10-14
  • 打赏
  • 举报
回复
update 表B set x3=a.x1
from 表B b inner join 表A a on a.X4=b.X4
where a.x2 between '2003-01-01' and '2003-01-31' '指定x2所在的时间段.
txlicenhe 2003-10-14
  • 打赏
  • 举报
回复
update b set b.x3 = a.x1
from 表A a
join 表B b on a.x4 = b.x4
where a.x1 在某一时间段(X2)

34,875

社区成员

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

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