我有以下查询
select main_cat_name,cat_url from mf_main order by main_cat_name这将返回表的全部数据.现在我想统计该表的总行数.我可以使用另一个查询来做到这一点,但是如何在一个查询中使用它们呢?
This returns whole data of my table.Now i want to have count of the total rows of this table.I can do it using another query but how can i use them in one single query???
我要两个数据ONE:-表的两行:-计数 我如何在一个查询中拥有它
I want two data ONE :- the rows of the table TWO:- the count how can i have that in one single query
我尝试了这个,但是它给出了正确的计数,但是仅显示表格的第一行:
I tried this but it gives correct count but displays only first row of the table :
select count(cat_id),main_cat_name,cat_url from mf_main order by main_cat_name推荐答案
您可以尝试使用分组方式,例如:
You can try with Group By like:
SELECT count(cat_id), main_cat_name, cat_url FROM mf_main GROUP BY main_cat_name, cat_url ORDER BY main_cat_name我希望正确的解决方案:
Right solution i hope:
这就是您想要的:)
SELECT x.countt, main_cat_name, cat_url FROM mf_main, (select count(*) as countt FROM mf_main) as x ORDER BY main_cat_name如果您使用mysql,您将像我一样拥有"as".对于其他人,db可能没有as(例如oracle)
If you use mysql u have "as" like i did. For others db may be without as (like oracle)
更多推荐
在一个查询中选择计数和其他记录
发布评论