mysql删除命令由 [英] Mysql delete order by

查看:46
本文介绍了mysql删除命令由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a table and I only display the latest 30 rows by order by ID.

我正在尝试通过下面的查询删除30个最新行之后的所有行.

I'm trying to delete any rows after the 30 newest rows by using this query below.

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

我一直在下面收到此错误

I keep getting this error below

#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

我在做什么错了?

推荐答案

尝试一下,

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

这篇关于mysql删除命令由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆