Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Probably simple question. How to limit to 30 results

Status
Not open for further replies.

JohnnyT

Programmer
Jul 18, 2001
167
GB
Hi

I've used MySQL before but never Access. I'm basically trying to get the first 30 records from an Access database and then, upon the person clicking to the next page, get the next 30 and so on.
I tried:
"SELECT * FROM my_table ORDER BY PROG_NO ASC LIMIT 30;";

But this didn't work. I searched the net and found out about the TOP command. I then tried.
"SELECT TOP 30 * FROM my_table ORDER BY PROG_NO ASC;";

But this hasn't worked either. Does anyone know what I'm doing wrong?

Thanks in advance for any light you can shed on this.

JT :)

I don't make mistakes, I'm merely beta-testing life.
 
[TT]SELECT TOP 30 * FROM my_table ORDER BY PROG_NO ASC[/TT]

Looks OK to me. I've just tried this:

[TT]SELECT TOP 5 * FROM Customers ORDER BY Customers.CompanyName ASC;[/TT]

in Northwind and it works.

When you say that your query doesn't work, what behaviour do you see? Does it crash or return the wrong records?

Geoff Franklin
 
alvechurchdata

The code above returns every row from the database. All 250 records.

Its as though the "TOP 30" bit isn't there...

Any ideas?

Thanks

JT

I don't make mistakes, I'm merely beta-testing life.
 
Add the primary key in the ORDER BY clause.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

Its working now. Many thanks for everyones help.

Now... on to the next problem.... :)

I don't make mistakes, I'm merely beta-testing life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top