At 12:53 +0800 5/13/03, Reagen Siedl wrote:
>Hi,
>
>Can anyone tell me if 3.23 is supposed to support "ORDER BY" in the
>delete command? I have tried it but keep getting errors.
ORDER BY is supported for DELETE as of 4.0.0.
>
>If it doesn't can anyone suggest a way to delete the last x number of
>records in a table ordering by a specified column.
You can do a SELECT to find the values that uniquely identify these
records, then use the values to construct the appropriate DELETE
statements. You may need to generate these DELETE statements
programmatically.
>
>Example:
>
>+----+---------+-------+-------+
>| id | my_name | class | total |
>+----+---------+-------+-------+
>| 1 | Reagen | Red | 10 |
>| 2 | John | Red | 3 |
>| 3 | James | Red | 8 |
>| 4 | Bob | Red | 6 |
>+----+---------+-------+-------+
>
>mysql> delete from table_name where class="Red" order by total ASC limit
>2;
>
>Should delete Bob and John.
>
>Any help would be greatly appreciated.
>
>Regards,
>
>Reagen Siedl