select *,(select count(1) from msgs where userid=users.userid) as 数量
from
users
from
users
解决方案 »
- 有一个产品数据表(有主键),我要知道这个产品总共卖了多少钱(明天早上结贴)
- 如何在asp中取得存储过程中的返回值?老师讲过,说需要用parameters集合来声明参数.但是,我没有听懂.请各位高手指点一下,举个简单的例子.
- ADO数据库连接问题/////////////////?????????????
- 调用存储过程出现 对象名 'select_Userss' 无效。
- 计算机改名了,怎么让SqlServer的服务再运行起来啊?
- 高分求人帮忙写公交换乘算法或给予RMB
- 分组查询 统计问题,高手赐教!
- 关于自定义函数的问题
- 关于权限的问题用SQL语句实现?急急!!!
- 不用UNION,只用一个SELECT,如何写?
- 大家帮我,急...........
- 这样的SQL该怎么写
from msgs left outer join users
on msgs.userid=users.userid
set msgcount=(select d.msg_count
from
(
select c.userid,c.username,count(c.title) as msg_count
from
(
select a.userid,a.username,b.title,b.content
from users a inner join msgs b on a.userid=b.userid
) as c
group by c.userid,c.username
)as d
where users.userid=d.userid
)
from (select count(userid) as cnt ,u.userid from users u inner join msgs m on u.userid=m.userid group by u.userid) um inner join users u um.userid=u.userid