Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Database LIMIT keyword

I'm trying to get my page listing function working in ASP with an Access database, but I don't know the alternative to LIMIT in Microsoft SQL. I have tried TOP but this doesn't seem to be working.

Here is the statement am using with MySQL:

SELECT  * FROM customers ORDER BY customerName DESC LIMIT 0, 5

How can I convert this to work with Access Database?

like image 810
Elliott Avatar asked Dec 29 '10 02:12

Elliott


2 Answers

According to ms-access view:

SELECT TOP(5) * FROM customers ORDER BY customerName; 

will fetch an error "The SELECT statement includes a reserved word",

the correct syntax is:

SELECT TOP 5 * FROM customers ORDER BY customerName; 

(note the brackets)..

like image 94
dEePaK Avatar answered Oct 05 '22 20:10

dEePaK


Top(5) is deceptive. Internally the database returns all records, then Access just shows the Top 5 rows. I'd use the LIMIT keyword instead of Top(n).

like image 35
xd9813 Avatar answered Oct 05 '22 18:10

xd9813