Update syntax query

Thanks to the book (Build your own database…) I now have a functioning MYSQL database which I am now learning to manipulate with .php stuff. I am able to update individual cells when, for example, visitors become members, but I would be grateful if anyone could help me out with the syntax for the following requirements:

  1. How to update a cell in the db by increasing the integer in it by 1.

  2. How to update each of six cells in a row, on separate occasions, one at a time, on the basis that the new input goes into the first unfilled cell in the row until all six are filled and an error message can be posted. The row can be identified by the user name and the six cells in question are initially set to ‘no’. I thought I could get away with doing an UPDATE…WHERE the first cell would be filled unless it was !=’no’ (i.e. already filled) and the second one would be filled WHERE the first one was !=’no’ AND the next one = ‘no’ (i.e. not already filled). But of course that ends up filling six cells with the first input. Duh! Now my brain hurts.

Any help greatly appreciated.

Peter

  1. UPDATE thetable SET thecolumn = thecolumn + 1

  2. this design fails first normal form, you need to add a separate table for the repeating values

Many thanks for that.

Peter

Hi edmundps, welcome to SitePoint! :wave:

I think your question could get better answers in the MySQL forum.

I’ll ask an Advisor to move the thread for you. :slight_smile:

Edit:

Oops… apparently I had an old tab open!

Glad you got an expert answer already! :slight_smile: