2017-06-02 6 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には、結果を制限するために「トップ」キーワードを使用してください。 SELECT TOP句を使用して、返すレコード数を指定します。

SELECT TOP句は、数千のレコードを持つ大きなテーブルで便利です。多数のレコードを返すと、パフォーマンスに影響を与える可能性があります。 Sytax:

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