Jump to content

How to order in UPDATE when using limit by?


Jessica

Recommended Posts

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!
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.