Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i flag every 10th record in a table?

Status
Not open for further replies.

nmc1975

MIS
Oct 23, 2001
15
0
0
US
Hi, hope someone out there can help me. I'm trying to flag a yes/no column with a "yes" on every ten records in a large table. How do I do this through an update query?

Your help is appreciated,
norm
 
I made a try.. It seems to be working.

REPLACE ALL Field WITH 'Y' FOR MOD(RECNO(),10) = 0

:)
 
I would think something like...

UPDATE Mytable SET flagfield = "yes" where mod(recno("Mytable"),10) = 0

...would do it, but I am not sure this is the best way.
Slighthaze = NULL
 
I posted and then saw your answer post...I see great minds think alike! :) Slighthaze = NULL
 
Hi

1. Scenario 1... The table has no deleted records.. and the recnumbers are the crieteria.

REPLACE ALL myFlag WITH MOD(RECNO(),10)=0

This will ensure that all the fields are flagged .t. or .f., depending on if it is 10th record or not.

2. Scenario 2... Deleted records are present..

DO a PACK before the above command..

3. Scenario 3 ... The table is ordered by a tag and with the index tag set, you need to flag the 10th in the order..

SELECT myTable
SET ORDER TO TAG myTab
nCount = 0
SCAN
nCount = nCount+1
REPLACE myFlag WITH MOD(nCount,10)=0
ENDSCAN

:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top