Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    3

    Angry Unanswered: Why can't I use ORDER BY with UPDATE

    In the UPDATE syntax at www.mysql.com/doc/en it says

    UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
    SET col_name1=expr1 [, col_name2=expr2, ...]
    [WHERE where_definition]
    [ORDER BY ...]
    [LIMIT #]


    The SQL-query I want to run is:

    UPDATE `resultat`
    SET raknasisnitt = 1
    WHERE tillhor = 8
    ORDER BY `totalt` ASC
    LIMIT 20

    But it won't work... mysql says
    You have an error in your SQL syntax near 'ORDER BY `totalt` ASC LIMIT 20' at line 1

  2. #2
    Join Date
    Jan 2003
    Posts
    3
    I though ORDER BY was used in SELECT operations when you want the data to be brought back in a certain order? I don't see how it could be used in UPDATE operations (though I could be wrong)

  3. #3
    Join Date
    Jan 2003
    Posts
    3

    Unhappy

    but the syntax...

    I'm trying to get around it now.. but I failed =/

  4. #4
    Join Date
    Sep 2002
    Location
    Kyiv, Ukraine
    Posts
    77
    Remove quotes?..

    Code:
    ...
    ORDER BY totalt ASC 
    ...
    Yours faithfully,
    Yaroslav Zaremba

  5. #5
    Join Date
    Jan 2003
    Posts
    3

    Wink

    it doesn't work.. same errormsg

    I think I have to mail to the mysql crew for this one

Posting Permissions

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