如果是一张表,我们可以通过select  x1,x2,(select count(*) from xxtable) as count
from  xxtable得到每次查询总共有多少条记录,我现在有两张表连接查询如下,我也想知道根据条件每次查询的总记录条数,着个sql语句怎么写??select  a.x1,a.x2,b.x3,x4
from  xxtable1 as a,xxtable2 as b
where a.id=b.id and (orther conditions)

解决方案 »

  1.   

    select  a.x1,a.x2,b.x3,x4,(select count(*) from  xxtable1 as a1,xxtable2 as b1 where a1.id=b1.id and (orther conditions) ) as cout
    from  xxtable1 as a,xxtable2 as b
    where a.id=b.id and (orther conditions)
      

  2.   

    加2个
    类似(select count(*) from xxtable) as count
    的子句不就行了吗?
      

  3.   

    select  a.x1,a.x2,b.x3,x4,(SELECT COUNT(*) FROM ... WHERE ...)
    from  xxtable1 as a,xxtable2 as b
    where a.id=b.id and (orther conditions)