Jessica Posted July 10, 2006 Share Posted July 10, 2006 I am performing this query:$update_item = "UPDATE stall_transactions SET cleared = 1 WHERE stall_id = $stall_id LIMIT 50";I want it to update the 50 most recent by either sold (datetime) or transaction_id (primary key). How can I ensure it does the 50 most recent?Thanks!ps: the new forum design is awesome! Quote Link to comment Share on other sites More sharing options...
designationlocutus Posted July 10, 2006 Share Posted July 10, 2006 Baffled me for a minute, but I was sure it was possible, so I had a look over at mysql.com.The following is the syntax for UPDATE. As long as you get the order correct, I'm sure you will have no problems.[code]UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_condition] [ORDER BY ...] [LIMIT row_count][/code] Quote Link to comment Share on other sites More sharing options...
fenway Posted July 10, 2006 Share Posted July 10, 2006 Yup... just add the necessary ORDER BY clause and you're set. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.