Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130662
  • 博文数量: 37
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2016-07-02 01:04
个人简介

CU

文章分类

全部博文(37)

文章存档

2016年(33)

2015年(4)

我的朋友

分类: LINUX

2016-01-16 01:33:28

1. 写法轻松,更新效率高:
update table1 
set field1=table2.field1,
field2=table2.field2
from table2
where table1.id=table2.id

 

2. 常规方式,种写法相当于一个 Left join, 以外面的where为更新条数,如果不加where就是所有记录

update table1
set field1=(select top 1 field1 from table2 where table2.id=table1.id)
where table1.id in (condition)

            转自http://blog.csdn.net/jcx5083761/article/details/26010763

    
阅读(1570) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~