View Full Version : Reset Fields back to 0?

01-19-2007, 09:57 PM
I've been running through some test where I have fields for a Win, Loss, and Tie. in a table.

Now that testing is almost complete. Is there a way to reset all rows back to a 0 value?

Lee Stevens
01-19-2007, 10:34 PM
In PHP My Admin, click Empty, and it'll reset the Table.

01-19-2007, 10:35 PM
well you can use one of two things.

if you want to remove the rows entirely then use TRUNCATE, it will still keep your table intact but remove all data.

that might not be what you want, even though it is fastest. if you have other data in those rows then you need to do an UPDATE on your table

wins = 0,
losses = 0,
ties = 0

and that will reset all those values.

Better still, in my opinion, if you are storing the results of football, hockey etc. etc., you are most likely already storing the score, either in this table or another one. Therefore you should not be storing wins, losses and ties at all, since these can be calculated by checking the game scores.

01-20-2007, 01:59 AM
Thanks. I didn't realize it was actually that simple.

But no, I'm not storing the game scores. Every new game results in about 3 new tables being created. So they all get deleted when there completed to help keep things manageable.

Thanks again though. I'm still a rooking at php and mysql, and didn't realize that it was simple of a query.

01-20-2007, 03:08 AM
You shouldn't be creating new tables every time you are introducing game scores. you should have a permanent table that would indicate

1) gameid
2) home team
3) home score
4) away team
5) away score

and you would add a new row for each game.

perhaps you could show us what you are saving and why you find it necessary to create new tables each time you introduce new data.

either I or someone else can help you improve what you are doing. as you say you are relatively new.