0

I`m rewriting an application that use MS Access as the database.

I was able to connect and fetch data from tables, but how can I apply limit and offset like SELECT * FROM tablename LIMIT 10 0?

elf1984
  • 301
  • 1
  • 4
  • 12

3 Answers3

3

SELECT TOP 10 * FROM tablename

Similar thread(no offset allowed in access)

Jayesh
  • 1,511
  • 1
  • 16
  • 37
  • SELECT TOP 10 * FROM tablename works but how can i get the next set like from 11-20 – elf1984 Jun 15 '11 at 10:09
  • 1
    [refer this](http://stackoverflow.com/questions/1900635/how-do-i-implement-pagination-in-sql-for-ms-access) – Jayesh Jun 15 '11 at 10:12
  • 1
    Actually offset clause is not supported by access as stated [here](http://forums.devshed.com/database-management-46/limit-and-offset-in-ms-access-was-ms-access-help-333247.html) too. But still you may apply a logic to achieve it as given in the link above. Sorry i rarely use access, so can't be of much help. – Jayesh Jun 15 '11 at 10:37
1

In Access the syntax is TOP n;

select top 10 * from tablename
Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • thanks for your fast reply, what will happen during pagination? because i still need the offset for pagination – elf1984 Jun 15 '11 at 10:03
  • See http://stackoverflow.com/questions/1900635/how-do-i-implement-pagination-in-sql-for-ms-access – Alex K. Jun 15 '11 at 10:07
0

http://phplens.com/lens/adodb/docs-adodb.htm#ex8 is much better solution. You can modify it a bit to suit your needs. By default it return in html table, which can be modified to get field names and specific number of rows as array

Raza Ahmed
  • 2,661
  • 2
  • 35
  • 46