SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [MySQL] UPDATE Clause

    Hello.

    I Need a rather simple update query.


    USER ~#

    Ronald 5000
    Ronald 4000
    Ronald 3000


    Now I am getting new value , e.g 5600 ( that's bigger than 1st row in the table )
    so I need update query for UPDATE a minimal row with this one i.e "Ronald 3000"

    New table should look:

    USER ~#

    Ronald 5000
    Ronald 4000
    Ronald 5600

    That's look really simple , but I am not experienced in sql so much.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    UPDATE tbl
       SET score = 5600
     WHERE name = 'Ronald'
    ORDER 
        BY score ASC
     LIMIT 1
    Hopefully you only have one ronald in the table.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks


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
  •