设为首页 加入收藏

TOP

update时连接表的语句
2014-11-24 00:04:33 来源: 作者: 【 】 浏览:11
Tags:update 连接 语句

update时连接表的语句
今天工作中遇到的个需求,需要将a表中的card_no字段赋值到b表中的card_no字段中,并且a表与b表是根据employee_no一对一的关系,这时就需要在更新的时候连接两个表了。
代码如下:
update a www.2cto.com
set a.car_no = (select card_no
from b
where b.employee_no = a.employee_no
)
where a.card_no is null--在给值为空的字段赋值,这句代码视情况而定。
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇left join,right join和inner joi.. 下一篇Postgres访问其他PostgresQL数据..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: