soft genic
soft genic

Reputation: 2056

Top in MS ACCESS

Kindly let me know how can I transform the following query in a way that it'll work perfectly in ms access:

$sql  = "SELECT * FROM Registration Limit 100,200";

I tried to use the following but it didnot work the way above query works in SQL.

$sql  = "SELECT TOP 100,200 * FROM Registration";

Upvotes: 0

Views: 82

Answers (1)

Ken White
Ken White

Reputation: 125669

You can't do it directly; Access doesn't support either of the LIMIT or TOP <countstart>, <countend> statements.

You can work around it, if you have an auto-increment (identity) column in your table (or something you can use instead to order rows):

SELECT 
  Top 100 reg.* 
FROM 
  registration reg
WHERE 
  reg.RegistrationID > 
  (
   SELECT 
     Top 100 r.RegistrationID 
   FROM 
    registration r
   ORDER BY
    r.RegistrationID
  )
ORDER BY
  reg.RegistrationID

Upvotes: 1

Related Questions