declare @t table(uid int,content char(10),hfid int)
insert @t
select 1,'...',0 union all
select 2,'...',0 union all
select 3,' ...',1 union all
select 4,' ...',1 union all
select 5,' ...',2
select *,
(select count(*) from @t where hfid = a.uid) as count
from @t a
where hfid = 0/*uid content hfid count
----------- ---------- ----------- -----------
1 ... 0 2
2 ... 0 1(所影响的行数为 2 行)
*/
insert @t
select 1,'...',0 union all
select 2,'...',0 union all
select 3,' ...',1 union all
select 4,' ...',1 union all
select 5,' ...',2
select *,
(select count(*) from @t where hfid = a.uid) as count
from @t a
where hfid = 0/*uid content hfid count
----------- ---------- ----------- -----------
1 ... 0 2
2 ... 0 1(所影响的行数为 2 行)
*/
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货