有两个表TB1,TB2,TB1里包含字段A1,A2,A3,TB2里包含字段B1,B2,B3。在TB1.A1=TB2.B1的条件下,我想把TB2里的B2内容修改成TB1的A2内容。这样的SQL语句怎么写?
解决方案 »
- 请问大家都用什么软件来写SQL
- 表有2列,第2列是数字,要求select中+3列,根据第二列的数字改变这三列,返回结果集,如结果集id=1,price=12,小于5=null,5-10=null,大于12=12
- xp_cmdshell的问题?急
- 我想将Select *查询出的数据集不经任何处理直接写进另一个和之前同样表结构的表中,请问能实现吗?
- SQL高难度分组查询
- 请教用先进先出法计算货品当前的结存情况!
- 请教一个关于三个表连结查询的sql语句
- sql编程问题!
- 怎样将一个指定的非备注型字段导出到文本文件中?(急急!!!50)
- 怎样获得连接到ODBC的SQL字符串?
- 求一条SQL语句!!
- 麻烦liang.ck再来看一下
set B2=A2
from TB2,TB1
where TB1.A1=TB2.B1
update tb2 set b2 = tb1.a2 from tb2 , tb1 where tb2.b1 = tb1.a1
set B2 = (select A2 from TB1 where TB2.B1=A1)
1,2楼的写法都是正确的
update b set b.b2=a.a2 from tb1 a join tb2 b on a.a1=b.b1
set b2 = tb1.a2
from tb2 , tb1
where tb2.b1 = tb1.a1
if object_id('test1') is not null
drop table test1
if object_id('test2') is not null
drop table test2go
create table test1(id int ,id1 int)
insert into test1 select 1,11
create table test2(id int ,id1 int)
insert into test2 select 2,2
union select 1,3
go
update test2
set test2.id1=test1.id1
from test1,test2
where test1.id=test2.id
go
select * from test2