日期:2014-05-18 浏览次数:20496 次
select qid,count(qid) as cis from test group by qid
select * from test as t1 where exists(select * from test as t2 where t1.QID=t2.ID) and t1.TID="&TID&"
select *, (select count(*) from test where qid=t1.qid)from test as t1 where exists(select * from test as t2 where t1.QID=t2.ID) and t1.TID="&TID&"
------解决方案--------------------
貌似LZ的那两条select语句没有什么关联,为何要合并呢?
------解决方案--------------------
select qid,count(qid) as cis from (select * from test as t1 where exists(select * from test as t2 where t1.QID=t2.ID) and t1.TID="&TID&") z group by qid
------解决方案--------------------
select *, (select count(*) from test where qid=t1.qid) from test as t1 where exists (select * from test as t2 where t1.QID=t2.ID) and t1.TID="&TID&"