2011-11-21 2 views
0

무엇 다음 MYSQL 쿼리의 SQL 서버 상당의 : 제품의SQL Server 쿼리의 시작은 제한

SELECT ID가 WHERE ID = '$ this-> idLIMIT 0, 10

+0

10, 20

* 중요 사용 'BY ORDER를'제한 처리하려면? http://stackoverflow.com/questions/7123036/is-there-a-way-to-get-different-results-for-the-same-sql-query-if-the-data-stays/7123084#7123084 또는 http://stackoverflow.com/questions/3879822/is-nolock-the-default-for-select-statements-in-sql-server-2005/3879846#3879846 – gbn

답변

3
SELECT * FROM ( 
    SELECT id, ROW_NUMBER() OVER (ORDER BY id) as row 
     FROM products where myparam='shopkeeper' 
) a WHERE a.row > 0 and a.row <= 10 
1

당신은 MSSQL에서 TOP 10을 사용할 수 있습니다

SELECT TOP 10 id FROM products WITH(NOLOCK) WHERE shopkeeper = '$this->shopkeeper' 

당신이 10-20에서 필요로하는 경우, n을거야 로이의 대답.

3

왜 맹목적으로 NOLOCK을 사용

SELECT TOP 20 FROM products WHERE id NOT IN(SELECT TOP 10 id FROM products ORDER BY id) ORDER BY id