The online racing simulator
MySQL problem
(8 posts, started )
MySQL problem
Hello!
I've attached the structure for my DB. I'm making teams tracker for long races and I have first problem here. I need to get teams ordered by laps done and total time and split in 1 query to display it. Here is my query, but it shows only data for 1st lap. On the next lap nothing changes in results and I have ldone = 1 for every row. I don't wonna use trigger but if no one will know how to fix it I will add some columns to teams table and with triggers or by InSim I will put there data.
Attached images
tracker db.png
i don't see anything terribly wrong with your table layouts, can we see the INSERT commands you're using?
Here are queries (packet : query):
LAP : $query = 'INSERT INTO {{table}}laps (driver, ltime, ttime, ldone) VALUES(:driver, :ltime, :ttime,:ldone)';
SPX : $query = 'INSERT INTO {{table}}splits (driver, lap, split, stime, ttime) VALUES(:driver, :lap, :split, :stime, :ttime)';
:lap is getted from last LAP packet + 1
ALL : $query = 'INSERT INTO {{table}}packets (time, data) VALUES(unix_timestamp(),:serialized)';
so if i understand it correct, you want it to list the team order, by sorting at Total time or Lap time ?

and are you sure that its pushing the data correct in the database ( or is that the problem)
i don't know if it'll help, just throwing it out there...

how about merging the "splits" table and the "laps" table together...

something like... (see attached)

that table is part of a DB that holds info acquired from the airio STA files, which i had tied into a website. it was working pretty good, last i checked.
Attached images
tracks-table.gif
Quote from bunder9999 :i don't know if it'll help, just throwing it out there...

how about merging the "splits" table and the "laps" table together...

something like... (see attached)

that table is part of a DB that holds info acquired from the airio STA files, which i had tied into a website. it was working pretty good, last i checked.

yea so that means that you have to update the record when it passes a split and insert a row when he drove past split one.

otherwise you wont get the tracker updated after every split.

but it sounds like a very good idea
Ok. So now I'm merging tables. Datas are putted correctly.

What is alternative for GROUP BY to get last LAP row for every team in JOIN query.
i'd do two queries... do one to get a list of drivers for the team, and then for the second query, pull all the laps they've done, order by id descending limit one.

MySQL problem
(8 posts, started )
FGED GREDG RDFGDR GSFDG