get a limit of records

  • Thread starter Thread starter w00
  • Start date Start date
W

w00

Guest
Hello, im currently working with a MS ACCESS database and with PHP.
I used to be working with MySQL alot and there was a functioin in MySQL that could get a number of records from the database.
So like if there are 100 records in the database if could get just 20 from it with the 'LIMIT' function which looked like this

SELECT * FROM table ORDER BY id DESC LIMIT 0,10

that means that it gets first record, then the second, and the third until it has 10.
But this function obviously doesnt work for MS ACCESS. So i was wondering what the equivalent was for this in ACCESS??
 
SQL_Hell said:
select top 20 * from table1
Hello, i tried it but it doesnt do the trick.
Ill give an example of what i mean, lets say i have 10 items in the database.
The first column is the ID, the second column is the name of a product.

1 name01
2 name02
3 name03
4 name04
5 name05
6 name06
7 name07
8 name08
9 name09
10 name10

If i would use "select top 3 * FROM table" then i would get

1 name01
2 name02
3 name03

if i said top 5 * i would've got

1 name01
2 name02
3 name03
4 name04
5 name05

But with MySQL i can say: "SELECT * FROM table LIMIT 3,5"
And that would give me:

4 name04
5 name05
6 name06

See how it skips the first 2 items, thats not because of the ID numbers, it just counting them.
So i need a function that can get the records between 2 numbers like i can with the LIMIT function.
Any idea how to do that with ACCESS??
 
I have never done this and there may be an easier way and a function that does this for you - but -

One query to select the top 5

second query to select top two.

thrid query selects the records from first query having no equivalent in the second.

You are left with 3 to 5.
 
Hi,

what about


select * from table
where (id < 7 and id > 2)
 

Users who are viewing this thread

Back
Top Bottom