Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts

    How to modify one value in MySql?

    Hi all,

    I've been beating my head against the wall for a few hours now and just not getting it.

    I have a message board database and I want to know the MySQL syntax for changing a value.

    It's in a database name "phpbb", the table is "phpbb_config" and the item name is "smiley_max_width" (there's also a max_height, but if I can do one I can do the other!)

    This is the bottom end of a "SELECT * FROM phpbb_config;" command:

    Code:
    | user_dst                     | 1                                                          |          0 |
    | smiley_max_width          | 36                                                         |          0 |
    | smiley_max_height         | 24                                                         |          0 |
    +------------------------------+------------------------------------------------------------+------------+
    281 rows in set (0.00 sec)
    Now, this command: SELECT * FROM phpbb_config WHERE config_name = "smiley_max_width";

    Gives me:

    Code:
    +------------------+--------------+------------+
    | config_name       | config_value  | is_dynamic |
    +------------------+--------------+------------+
    | smiley_max_width | 36           |          0 |
    +------------------+--------------+------------+
    1 row in set (0.00 sec)
    All I want to do is be able to MODIFY the value of "36" programmatically.

    Thanks......

    -- Roger
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    MODIFY is used to change the structure of the table itself.
    UPDATE is used to change the values in the table.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,567
    Thanks
    78
    Thanked 4,385 Times in 4,350 Posts
    Code:
    UPDATE phpbb_config SET config_value = '93817 bonanza' WHERE config_name = 'smiley_max_width';
    That's probably not the value you want, but it's a fun value.

    Pardon me for asking, but did you consider just looking in the MySQL docs?

    http://dev.mysql.com/doc/refman/5.1/en/update.html
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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