SunQuest
           MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old June 17th, 2004, 10:02 AM
Dieter's Avatar
Dieter Dieter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: SA, Centurion
Posts: 305 Dieter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 16 m 26 sec
Reputation Power: 6
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

Reply With Quote
  #2  
Old June 19th, 2004, 04:28 PM
lucasalexander lucasalexander is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Atlanta
Posts: 39 lucasalexander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to lucasalexander Send a message via MSN to lucasalexander
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

Reply With Quote
  #3  
Old June 21st, 2004, 12:36 AM
Dieter's Avatar
Dieter Dieter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: SA, Centurion
Posts: 305 Dieter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 16 m 26 sec
Reputation Power: 6
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

Reply With Quote
  #4  
Old June 22nd, 2004, 02:01 PM
timmyd timmyd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 8 timmyd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old June 23rd, 2004, 12:59 AM
Dieter's Avatar
Dieter Dieter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: SA, Centurion
Posts: 305 Dieter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 16 m 26 sec
Reputation Power: 6
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 !

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > select every 100th db entry ??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway