日期:2014-05-18  浏览次数:20465 次

请教一下大家,关于嵌套查询?的问题



这是表的关系,数据库是类似于QQ的数据库。
我现在要修改,好友人数(count(*) from dbo.Relation where RelationStatus=0)大于20的所有QQ号等级+1(update QQuser set level=level+1)

我的问题是:这个update语句怎么写条件?
升级列数据与条件存在的表非同一表,where语句怎么写?

------解决方案--------------------
SQL code
update a set level=level+1
from QQuser  a
where a.qqid 
in
(select qqid from Relation where RelationStatus=0 group by qqid  having count(*)>20)