Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...