using phpMyAdmin sql to selectively update fields

Discussion in 'MySQL' started by mipa jim, Jul 24, 2006.

  1. #1
    I'm trying to update selective fields using sql in phpmyadmin

    something like this

    update 'recipes' when category = wings set bookimage = "wings.gif"

    Can't seem to understand all the help stuff and get it to work.

    thks
     
    mipa jim, Jul 24, 2006 IP
  2. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    update 'recipes' set bookimage = "wings.gif" where category = "wings"
     
    rosytoes, Jul 24, 2006 IP
  3. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What rosytoes said but just to add, you might want to go 'Operations' and copy a backup of the lot first.
     
    T0PS3O, Jul 24, 2006 IP
  4. mipa jim

    mipa jim Peon

    Messages:
    261
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I made adjustment for exact. other than that I posted exactly but get this error still.
    Thks though

    Error

    SQL query:

    UPDATE 'recipes' SET bookimage = "wings.gif" WHERE category2 = "Chicken Wings"

    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''recipes' set bookimage = "wings.gif" where category2 = "Chicke
     
    mipa jim, Jul 24, 2006 IP
  5. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    the quotes on either side of recipes are a double and a single? either loose the quotes all together or use the `. It is the key to the left of the number one key on my keyboard.
     
    rosytoes, Jul 24, 2006 IP
  6. mipa jim

    mipa jim Peon

    Messages:
    261
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Excellant. THe backward quote did it. How can you know which one to use? Just trial and error?
     
    mipa jim, Jul 24, 2006 IP
  7. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    afaik, the backward quote is only used for table names, I always use single or double quotes for strings or variable names.
     
    rosytoes, Jul 24, 2006 IP