MySQL Forums
Forum List  »  Newbie

Re: I need a column that automatically adds the new number with the old number. Possible?
Posted by: Peter Brawley
Date: May 27, 2021 10:30AM

A table without a primary key is incomplete, and the Insert ... On Duplicate Key Update... command illustrates this, because without a key it can never find a key to update. You forgot to give your table a PK. Without a PK, your cmd simply adds a row for ed, 19 points.

After ...

alter table tbl_points add primary key(name);

... your cmd works as expected.

Consider reading a primer on relational databases, eg https://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch01.html

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.