0

这在 Mysql 中有效,但似乎 MariaDB 的语法不同,我试图删除前 900 个返回行(LIMIT 900)以上的任何内容:

DELETE FROM cronschedule NOT IN (SELECT * FROM cronschedule LIMIT 900);

尝试在 Maria 中执行此操作会返回以下错误:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that 
corresponds to your MariaDB server version for the right syntax to use near 
'NOT IN (SELECT * FROM cronschedule LIMIT 900)' at line 1

那么我将如何在 Maria 中做到这一点?

4

2 回答 2

2

我希望这比您对LEFT JOIN / IS NULL构造的回答更有效:

DELETE  cr.*
FROM    cronschedule cr
    JOIN
        (
        SELECT  id
        FROM    cronschedule ii
        ORDER BY
                id ASC
        LIMIT 1 OFFSET 900
        ) i2
ON      cr.id >= i2.id ;
于 2013-10-24T16:51:47.153 回答
1

这似乎有效

DELETE  cr.*
FROM    cronschedule cr
LEFT JOIN
        (
        SELECT  id
        FROM    cronschedule ii
        ORDER BY
                id ASC
        LIMIT 900
        ) i2
ON      cr.id = i2.id
WHERE   i2.id IS NULL;
于 2013-10-24T15:34:12.377 回答