|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
||||
|
||||
|
select every 100th db entry ??
Hi,
How can I make a query from my db in order to select every 100th entry eg: 100,200,300,400.....n I know how to do it when using php to access the db, but would like the query to handle it THANKS !!
__________________
:P
|
|
#2
|
|||
|
|||
|
You could write a cursor that loops through the table and increments a counter for each loop. Add some code to the cursor inserts every nth row into a temporary table, and then select all the rows from the temp table when the cursors is done. From a performance perspective, you might be better off doing the processing outside of the database, but I can't say for sure.
__________________
Lucas Alexander http://www.alexanderdevelopment.net |
|
#3
|
||||
|
||||
|
I also thought of doing it that way, I was just wondering if a single query eg: "SELECT * from DB WHERE ......" would be able to handle this.
Thanks anyway ![]() |
|
#4
|
|||
|
|||
|
Do you have an auto incrementing ID field? If so you could do something to the effect of:
Code:
SELECT * FROM tableName WHERE ID % 100 = 0 |
|
#5
|
||||
|
||||
|
Thanks, but I decided to rather do as lucasalexander suggested. I do have a auto increment, and gues it will work your way but rows gets deleted sometimes and that makes the auto-increment not so accurate.
I know there are ways to by-pass this, but seems like to much admin. Thanks anayway ! ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > select every 100th db entry ?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|