2017-06-02 23 views
0

我必須每人民的幫助下一個問題: 在MySQL中,我的查詢:在MySQL和SQL Server中查詢?

select * from readquestion where readexerciseid= "+readexerciseid+" limit "+(start-1)+", "+count+"; 

我想問問這個查詢在SQL Server中,我應該怎麼辦呢?

+0

你嘗試CONCAT()?如果是,請粘貼查詢和錯誤。作爲參考:https://stackoverflow.com/questions/5734570/mysql-select-with-concat-condition – Deep

回答

0

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