Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我该怎么做呢?我已经有一个带有自动增量和主键的 id 字段。但是,是的,我需要一个执行此操作的脚本。我到处查看它只是向我展示了如何删除单行但从不按顺序删除多行。
您需要LIMIT删除 12 行,您需要对其进行设置,以便将其删除WHERE到应开始id的>=id。
LIMIT
WHERE
id
>=
如果我想id从表中删除 12 行,从(包括)4开始foo:
foo
DELETE FROM `foo` WHERE `id` >= 4 ORDER BY `id` ASC LIMIT 12
您可以定义任何您喜欢删除数据的顺序。并且limit您可以限制要删除的记录数
limit
delete from your_table order by id asc limit 12