删除前100条数据,根据主键ID排序。

WBOY
Release: 2016-06-23 13:50:12
Original
1342 people have browsed it

sql语句怎么写啊?

delete from visitrecord where id in (select top 100 from visitrecord order by id asc)
Copy after login

这样写有什么错误吗?


回复讨论(解决方案)

delete from visitrecord where id in (select id from visitrecord order by id asc limit 100)

delete from visitrecord limit 100
Copy after login

delete from visitrecord where id in (select id from visitrecord order by id asc limit 100)

 This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery

delete from visitrecord where id in (select top 100 from visitrecord order by id asc)
你的这个写法是sqlserver的

mysq写法如下
delete from visitrecord where id in (select id from visitrecord order by id asc limit 100);

都是大神啊,我轻飘飘的路过~~~

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!