SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for that.

    Peter

  4. #4
    Design Your Site Team bronze trophy Erik J's Avatar
    Join Date
    May 2007
    Location
    Countryside, Sweden
    Posts
    3,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi edmundps, welcome to SitePoint!

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

    I'll ask an Advisor to move the thread for you.

    Edit:


    Oops... apparently I had an old tab open!

    Glad you got an expert answer already!
    Happy ADD/ADHD with Asperger's


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •