Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
261 views
in Technique[技术] by (71.8m points)

How to delete multiple rows in sqlite database

I have a table in sqlite database which consists of 61249 rows in that i just need 873 rows rest of the rows have to be deleted. I tried it by using loops concept but unfortunately. I am using dbbrowser sqlite to access this database. we cant use loops here can any one solve this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

if you know how to select your 873 rows from your table you should do something do like this. Here is how to delete all rows except selected, in this example all rows except those where id is between 3 and 5...

 DELETE FROM table1
 WHERE id NOT IN (SELECT id FROM table1 WHERE id BETWEEN 3 AND 5);

Here is SQL Fiddle for that to see how that look like http://sqlfiddle.com/#!7/3d657/1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...