需求就是根据用户ID,获取该用户的相关统计信息,如好友数、短消息数、日志数以及系统短信等等
这些表之间没有建主外键关系,uid是用户表[customer]的主键,这里没涉及它
declare @userid int
select @userid=3这句:select 
(select count(*) from [note] where uid = @userid) as count1,
(select count(*) from [mynote] where uid = @userid) as count2,
(select count(*) from [notebook] where uid = @userid) as count3,
(select count(*) from [friend] where uid = @userid) as count4,
(select count(*) from [message] where oppuid = @userid) as count5,
(select count(*) from [message] where msgtype = 0) as count6