我有一个问题需要大家帮忙: 在Mysql中,我的查询:
select * from readquestion where readexerciseid= "+readexerciseid+" limit "+(start-1)+", "+count+";
我想问一下在SQL Server中这个查询,我应该怎么做?
最佳答案
在 SQLServer使用“top”关键字来限制结果。 SELECT TOP 子句用于指定要返回的记录数。
SELECT TOP 子句对于具有数千条记录的大型表很有用。返回大量记录可能会影响性能。 语法:
SELECT TOP number|percent column_name(s)
FROM table_name
WHERE condition;
例如:
int count = start - 1 + count; //calculate limit here
"select top "+ count +" * from readquestion where readexerciseid= "+readexerciseid
注意:并非所有数据库系统都支持 SELECT TOP 子句。 MySQL 支持 LIMIT 子句来选择有限数量的记录,而 Oracle 使用 ROWNUM。 在mysql中使用'limit'关键字来限制结果。
语法:
SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;
例如:
int count = start - 1 + count; //calculate limit here
"select * from readquestion where readexerciseid= "+readexerciseid+" limit "+ count
关于mysql - 在 MySQL 和 SQL Server 中查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44325173/