2

In an ASP page (VBScript) that gets a recordset from a *.MDB Access database, how can I simulate the LIMIT clause of MySQL in the SQL?

<%
    Dim cn,rs
    Set cn = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Recordset") 
    cn.Open dbConnectionString
    Dim sql
    sql = "SELECT * FROM mytable LIMIT 10,50"
    Set rs = cn.Execute(sql)
%>
Max
  • 4,965
  • 17
  • 49
  • 64

1 Answers1

4

In Access, limiting results to the top X results look like this.

MySQL

SELECT * FROM mytable LIMIT 10

Access

SELECT TOP 10 * FROM mytable

If you would like to use an offset, like in your example, check this answer:

MS Access LIMIT X, Y

Community
  • 1
  • 1
Tom
  • 6,593
  • 3
  • 21
  • 42
  • Does that offset method syntax work with SQL Server too? If it does then I'm bookmarking that question – John Feb 26 '14 at 16:16
  • 1
    Here's a link for SQL Server http://stackoverflow.com/questions/2135418/equivalent-of-limit-and-offset-for-sql-server/2135461#2135461 – Tom Feb 27 '14 at 00:14