select a.x1,a.x2,b.x3,x4
from xxtable1 as a,xxtable2 as b
where a.id=b.id and (orther conditions)
...全文
6654打赏收藏
mysql 连接查询,如何得到总的记录条数
如果是一张表,我们可以通过 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)
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)