Click to See Complete Forum and Search --> : limiting a query


pelegk1
10-26-2005, 09:31 AM
can i linit a query like in mysql Server where i can ask in the query
lines 20-30 like this:
select * from table1 limit 20,10
which means tgive me the first 10 rows sarting with line 20
thnaks in advance
peleg

buntine
10-26-2005, 08:58 PM
Are you using MS Access? If so, I do not think you can limit the query in the same way. You may be able to, but I have never come across it.

You can, however, use the TOP clause.

SELECT TOP 10 * FROM TableName ORDER BY TableNameID;

If you're using MS SQL, you may be able to use a CASE or similar conditional statement to begin ordering at a certain point. See: http://www.siteexperts.com/forums/viewConverse.asp?d_id=17279&Sort=0

Regards.

buntine
10-26-2005, 08:59 PM
Workaround for MS SQL: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=850&lngWId=5

pelegk1
10-27-2005, 12:45 AM
i work with sql server
and what i wanted to do is paging - sorry for not using the correct word from starts!
the link i used is :
http://www.asp101.com/articles/recordsetpaging/index.asp (paging)
and the solution that buntine gave me in the link i have a better 1 i belive :

select top 5
*
from
(
select top 10
*
from
companies
order by row_num DESC
)aa
order by row_num DESC


simple isnt it but not effective when i have 1 million rows!

buntine
10-27-2005, 02:37 AM
But good enough. ;)