小编典典

mysql删除命令由

mysql

我有一张桌子,我只按ID顺序显示最新的30行。

我正在尝试通过使用以下查询删除30个最新行之后的任何行。

DELETE FROM table WHERE type = 'test' ORDER BY id DESC LIMIT 30, 60

我不断收到以下错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 60' at line 1

我究竟做错了什么?


阅读 685

收藏
2020-05-17

共1个答案

小编典典

试试这个

DELETE FROM table
WHERE ID IN
        (
        SELECT ID
        FROM
            (
                SELECT ID
                FROM table
                WHERE Type = 'TEST'
                ORDER BY ID
                LIMIT 30,60
            ) a
        )
2020-05-17