Please support our MS Access and FileMaker Pro advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jan 2009
Posts: 35
Reputation: headedtomexico is an unknown quantity at this point 
Solved Threads: 0
headedtomexico headedtomexico is offline Offline
Light Poster

LIMIT, TOP help

 
0
  #1
Jul 23rd, 2009
So i'm used to using mysql, but i'm on a project right now that uses an access database, and I'm looking for a way to replace LIMIT. I googled around and found the information on TOP, but it doesnt totally replace the functionality. For example if a user were to search the database for phone numbers of anyone named jim... and wanted to page through 50 at a time it would look something like this in mysql.

SELECT phonenumber FROM users WHERE firstname= 'jim' LIMIT 0, 50;
That would return the first 50, page 2 would look like:
SELECT phonenumber FROM users WHERE firstname= 'jim' LIMIT 49, 50;
page 3
SELECT phonenumber FROM users WHERE firstname= 'jim' LIMIT 99, 50;
Using the TOP clause I would do something like
SELECT TOP 50 phonenumber FROM users WHERE firstname= 'jim'
That would only get me my first page.... how do I tell it to skip a certain number of records, then grab 50.
Last edited by headedtomexico; Jul 23rd, 2009 at 8:47 pm.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 35
Reputation: headedtomexico is an unknown quantity at this point 
Solved Threads: 0
headedtomexico headedtomexico is offline Offline
Light Poster

Re: LIMIT, TOP help

 
0
  #2
Jul 23rd, 2009
OK, i found the answer, I guess I was being hasty when i did it, here it is if anyone else stumbles onto this post needing help

Page1
SELECT TOP 50 phonenumber FROM users WHERE firstname = 'jim';
Page2
SELECT TOP 50 phonenumber FROM users WHERE firstname= 'jim' AND phonenumber NOT IN (SELECT TOP 50 phonenumber FROM users WHERE firstname = 'jim') ;

Page3
SELECT TOP 50 phonenumber FROM users WHERE firstname= 'jim' AND phonenumber NOT IN (SELECT TOP 100 phonenumber FROM users WHERE firstname = 'jim');
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS Access and FileMaker Pro Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC