SQLSERVER,一条SQL语句返回查询结果集和全表记录数 20
select*fromTableselectcount(*)fromTable一条SQL能解决上述需求吗?...
select * from Table
select count(*) from Table
一条SQL能解决上述需求吗? 展开
select count(*) from Table
一条SQL能解决上述需求吗? 展开
2015-04-03
展开全部
你可以只用这一条SQL
select * from Table
然后用mysql_num_rows() 获取记录数
select * from Table
然后用mysql_num_rows() 获取记录数
追问
what mysql_num_rows() ?
追答
$query = mysql_query("select * from Table");
mysql_num_rows($query);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from Table
compute count(字段)
--或者
select *,COUNT(*) over() As 记录总数 from 表
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sql server 和 oracle通用:
select t1.*,(select count(*) from table_name) as all_rows
from table_name t1;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select count(1) from Table 这样比较好
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT
QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) + '.' + QUOTENAME(sOBJ.name) AS [TableName]
, SUM(sdmvPTNS.row_count) AS [RowCount]
FROM
sys.objects AS sOBJ
INNER JOIN sys.dm_db_partition_stats AS sdmvPTNS
ON sOBJ.object_id = sdmvPTNS.object_id
WHERE
sOBJ.type = 'U'
AND sOBJ.is_ms_shipped = 0x0
AND sdmvPTNS.index_id < 2
GROUP BY
sOBJ.schema_id
, sOBJ.name
ORDER BY [TableName]
GO
QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) + '.' + QUOTENAME(sOBJ.name) AS [TableName]
, SUM(sdmvPTNS.row_count) AS [RowCount]
FROM
sys.objects AS sOBJ
INNER JOIN sys.dm_db_partition_stats AS sdmvPTNS
ON sOBJ.object_id = sdmvPTNS.object_id
WHERE
sOBJ.type = 'U'
AND sOBJ.is_ms_shipped = 0x0
AND sdmvPTNS.index_id < 2
GROUP BY
sOBJ.schema_id
, sOBJ.name
ORDER BY [TableName]
GO
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询