Query - retrieve a set number of records (1 Viewer)

j0se

Registered User.
Local time
Today, 16:37
Joined
Jan 15, 2003
Messages
57
Hi all,

I want to retrieve a set number of records from a table, using a query. I'm not sure of how to do this.

I can't use the ID, because the table gets its data replaced contantly by imports (so the ID doesn;t start at 1...)

I want to be able to retrieve, say, the first 25 records on that table.

Any help is appreciated
 

Mile-O

Back once again...
Local time
Today, 16:37
Joined
Dec 10, 2002
Messages
11,316
I won't ask why you replace data, but you use the TOP keyword in your SQL.

i.e.

SELECT TOP 25
 

j0se

Registered User.
Local time
Today, 16:37
Joined
Jan 15, 2003
Messages
57
Top

That's great!!! It works great - I just need one more bit of knowledge, if you would spare me :)

* The reason I replace data is simply that it is a small app that imports csv data into a table, modifies it, then exports it into XL. Each import replaces the last.

Basically, I'm storing the number of imported files in an array, along with their recordCount.

e.g.

file 1: 20 records
file 2: 52 records
.
.
.
.

Now, I'm ready to export the data to XL, but I would like to create a spreadsheet with a worksheet for each imported file - hence, I need to loop through my array with a query that's going to do:

Select from 1 to 20 from ....
Select from 21 to 52 from ....

The TOP statement works great for the first statement, but is there a NEXT or similar keyword I can use for the rest?

PS I found the solution BUT for MySQL:
SELECT * FROM employees LIMIT 10,10; (this would skip the first 10 records)

Thanks for your prompt reply!
 
Last edited:

Users who are viewing this thread

Top Bottom