日期:2014-05-17  浏览次数:20502 次

求大虾回答个简单的SQL语句
我表里有userid usertype data a b c d 这7个字段 
usertype  有10 和 25 两种类型 
a=b+c+d
userid 有很多人 每个人都有这2种类型 其中usertype =10 的里还分 data=2011 ,data=2012,data=2013 3种  usertype =10 里只有data=2013 一种

我现在想让 usertype = 10 的每个人的 a=(a-b+c)(括号里的a-b+c是当前人的 且 usertype = 25 且data=2012 这行里的a,b,c)

麻烦有会的帮忙看看这个SQL 语句应该怎么写!
SQL语句 SQL问题

------解决方案--------------------
update a set a.a=b.a-b.b+b.c TableName a inner join TableName b on a.userid=b.userid and a.usertype=10 and  b.usertype = 25 and b.data=2012
------解决方案--------------------
update a set a.a=b.a-b.b+b.c from HR_ATS_HolidayLimita inner join HR_ATS_HolidayLimit b on a.userid=b.userid and a.usertype=10 and  b.usertype = 25 and b.data=2012