使用 DELETE 语句从单个表中删除数据,语法格式为:
DELETE FROM <表名> [WHERE 子句] [ORDER BY 子句] [LIMIT 子句]
语法说明如下:
<表名>
:指定要删除数据的表名。ORDER BY
子句:可选项。表示删除时,表中各行将按照子句中指定的顺序进行删除。WHERE
子句:可选项。表示为删除操作限定删除条件,若省略该子句,则代表删除该表中的所有行。LIMIT
子句:可选项。用于告知服务器在控制命令被返回到客户端前被删除行的最大值。注意:在不使用 WHERE 条件的时候,将删除所有数据。
- delete from exam_record
- where submit_time is null or timestampdiff(minute,start_time,submit_time) <5
- order by start_time
- limit 3
- DELETE FROM exam_record
- WHERE start_time IN (
- select *
- from
- (SELECT
- start_time
- FROM
- exam_record
- WHERE submit_time IS NULL or timestampdiff(MINUTE,start_time,submit_time) < 5
- ORDER BY start_time
- LIMIT 3) a
- )
同时,mysql环境中不允许先
select
一些值再
delete
,需要外层再套
select
* 解决
但是允许select一个值在delete
(4条消息) 删除行.聚合函数(汇总数据)_愈努力俞幸运的博客-CSDN博客https://blog.csdn.net/qq_37891604/article/details/127016146