易截截图软件、单文件、免安装、纯绿色、仅160KB

求教sql语句

如下:
有 A 表

name sex age

tom man
marry woman

B表

name age

tom 12
marry 13


如何用update语句将B表中的age更新到A表中的age中?


引用
SQL code

updata A
set age = (select age from B where name = A.name)
where exists(select 1 from B where name = A.name)

SQL code:

update A
set age = (select age from B where name = A.name)
where exists(select 1 from B where name = A.name)




update a set age = (select age from b where name = a.name);


学习了

答案都给全了~我还写了个!

update a set a.age=b.age from b where a.name=b.name

update A
set age = B.age
from A 
join B 
on A.name = B.name



SQL code:
UPDATE A SET age=(select age from B where B.NAME=A.NAME);



相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

ASP链接SQL的简单登陆界面 - .NET技术 / ASP.NET

protected void btnLogin_Click(object sender, EventArgs e)
  {
  SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......

求一sql语句 - MS-SQL Server / 疑难问题

现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......

两句SQL并一句,有问题. - MS-SQL Server / 基础类

第一句:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm 
 join jh on ht.htbh=jh.hth 
and ht.htbh not like'del%' and ht. ......

vs2008 连接mysql? - MS-SQL Server / 基础类

请问
添加新数据源->数据库->添加连接
这个界面下,数据源选择:Microsoft SQL Server (SqlClient);
服务器名:
应该写什么呢?
有谁知道?多谢各位!!
你到底是要连mysql还是mssql?

引用
请问
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号