Question: I'm new to mysql and wanted to consult about using mysql for my mini game. The idea is that from a game i get two variables - one is email, and another is score.

I'm thinking of creating a table with two columns and setting email as the primary.

The question is how do I make php script replace score value for a player which tries for the second time? 

For example user@user.com scores 100 in the first try, script adds that as INSERT INTO table VALUES ($email,$score); then user tries another time, same script tries to add but gets duplicate error. Any help on script logic would be great! cheers

Answer: 
```
INSERT
INTO    mytable (email, score)
VALUES  ($email, $score)
ON DUPLICATE KEY
UPDATE
SET     score = $score

```

This requires `email` to be the `PRIMARY KEY` of `mytable`.
It's difficult to answer without more details. If there is some sort of session or pre-registering of the player, you could insert a "default score" of zero, for instance, and then always update instead of insert. If not, Queassnoi's solution is probably the best.