update table1 from table2 set table1.col2 =table1.col2 where table1.col1=table2.col2
解决方案 »
- 如何sql语句查询出数据库每个表的几条数据?
- sqlserver2005两个实例做映射时,
- 1,4-10,30 这种形式,如何拆成 9条记录,字段值分别是1,4,5,6,7,8,9,10,30
- 从表中组合取数,急,求救!!!!!!!!!!!!!!!!
- 如何判斷一個表是否有從表呢?
- FOR循环数据插入重复的问题
- SQL SERVER 2K I/O读取过大及内存占用问题(研究效率高手请)
- 表合并
- insert触发器,批量插入如何设置ID?
- 语法规则问题 [code=SQL]create proc[edure] procedure_name[;number]
- 为什么我的SQL Sever不能自动启动!?
- 简、繁体共用的问题,期待最完美的答案。
col1 col2
1 v
2
3 e
4
set table1.col2=table2.col2
from table1 left join table2 on
table1.col1=table2.col1
update table1 set col2=a.col2 from table2 a where table1.col1=a.col1
table1:
col1 col2
1
2
3
4
table2:
col col2
1 v
3 e
6 r
2 y
要求如下:
根据tabl1.col1=tabl2.col 更新table1,使其的值如下所示.
col1 col2
1 v
2 y
3 e
4 就是对的!
感谢楼上所有的解决方法。