This sounds like run of the mill stuff. A few comments:
You are storing the names of the top 50 finishers in a race in a single
row, if that is what you truly meant, that sounds like it must be violating
some form of database design, although I don't know enough right now to
make that distinction.
You can execute a query with the CFQUERY tag. ColdFusion creates a
variable, with the query data that is a structure of arrays (or was it an
array of structures?). You can cycle through the records using cfloop or
cfoutput. It sounds like you may want to use grouping.
At 04:47 PM 01/23/2002 -0800, you wrote:
>I have a database of race results cover six years.
>The results table has a date field, race name field,
>and fields for the first 50 finishers. I also have a
>race name table and a racers table. The fields in the
>results table are populated with the corresponding key
>fields for the race and runners.
>
>The user will select a racer to query. I need to loop
>through the results table and do two things: 1) check
>the name of the race, and 2) check with field that the
>runner finished in each race. (first loop, check all
>race #1 entries and placement of runner #1, second
>loop check all race #2 entries and placement of runner
>#1, etc.
If I'm understanding the table structure based on what you are
saying. You have a table structure like this:
racer (RaceID, Racenamefield, Racedate, firstplaceRacerID,
SecondPlaceRacerID, ThirdPlaceRacerID, .... FiftiethPlaceRacerID )
If so... you can get your results in a single query, like this:
Select * from results
where finisher1ID = racerID or
finisher2ID = racerID or
finisher3ID = racerID or ...
I hope that is not what you are doing. I hope that you have created a
structure like this:
race (RaceID, Racenamefield, Racedate )
Racer (RacerID, OtherRacerInfo )
RacerRace (RaceID, RacerID, Placement )
Then, if you can query like this:
select * from race, racer, racerrace
where Race.raceID = racerrace.raceID and
racer.racerID = RacerRace.racerID
>For results, I need to show the name of each race, and
>the number of top 5 finishes, top 10 finishes, top 15
>finishes and average finish that that runner has had
>in that particular race over the years.
I'm not quite sure what you mean by returning the top 5 finishes, top 10
finishes, top 15 finishes. Wouldn't the top 10 include the top 5?
okay.. in the second table structure, you can do something like this to
get the data:
select * from race, RacerRace, Racer
where race.raceID in (select raceID from RacerRace where
RacerRace.racerID = racerID) and
raceracer.raceID = racerrace.raceID and
racerrace.racerID = racer.raceID and
racerrace.placement < 15
group by race.race
>I'm confused as to whether to use cfswitch or cfif
>statements. Or whether I should use arrays. Could
>someone give some guidance, and possible examples of
>how the code should look?
I think you need to concentrate on your database before you worry about
dealing with it in ColdFusion.
--
Jeffry Houser | mailto:[EMAIL PROTECTED]
AIM: Reboog711 | ICQ: 5246969 | Fax / Phone: 860-223-7946
--
DotComIt: Database Driven Web Data
My Book: Instant ColdFusion 5 | http://www.instantcoldfusion.com
My New Book: ColdFusion: A Beginner's Guide February 2002
--
Far Cry Fly, Alternative Folk Rock
http://www.farcryfly.com | http://www.mp3.com/FarCryFly
______________________________________________________________________
Why Share?
Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation � $99/Month � Free Setup
http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists