mysql 连接查询,如何得到总的记录条数

weinideai 2011-03-30 12:24:06
如果是一张表,我们可以通过

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)
...全文
665 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2011-03-30
  • 打赏
  • 举报
回复
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)
wwwwb 2011-03-30
  • 打赏
  • 举报
回复
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)
gungod 2011-03-30
  • 打赏
  • 举报
回复
加2个
类似(select count(*) from xxtable) as count
的子句不就行了吗?

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧