更新时间:2023-02-06 11:04:13
这将删除除最后一行之外的所有行。
This will delete all the rows except the last row.
Delete from UserTable where Id not in (select Id from UserTable ORDER by Id desc)";
如果你只是想要删除除最后一行之外的所有行。你可以使用MAX(..)函数。
写一个像这样的SQL,删除Id小于max的所有行。
If you just want to delete all rows except the last one. You can use MAX(..) function.
Write a SQL like this, deletes all rows where Id is less than max.
DELETE FROM UserTable WHERE Id < (SELECT MAX(Id) FROM UserTable)