Mysql 删除前十条外的数据

蛋黄卷蛋卷 发布于 2017/07/07 15:49
阅读 229
收藏 0

新的需求里包含这么个操作,删除除了 前十条之外的数据。。。试了几种方法都不行,求教。。

DELETE FROM 
t_deal_copy as d,(select t_deal_copy.deal_id from t_deal_copy LIMIT 9,1) as t
WHERE
d.deal_id > t.deal_id
[Err] 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 'as d,(select t_deal_copy.deal_id from t_deal_copy LIMIT 9,1) as t
WHERE
d.deal' at line 2

加载中
0
蛋黄卷蛋卷
蛋黄卷蛋卷

好吧 自己解决了 完结。。。

0
doukou
doukou

DELETE FROM 
t_deal_copy 

WHERE id not in(SELECT id from (SELECT id from t_deal_copy order by id limit 10) a)

0
skhuhu
skhuhu

mysql 不支持子查询的update insert

返回顶部
顶部