7

MySQL delete excess rows over limit

view full story
linux-howto

http://stackoverflow.com – My Android app employ MySQL to store data. The data is loaded into a listview and I wanted to limit the entries to 300-500 for performance. However I am having trouble writing a sql query that will handle this. My initial thoughts where to get the count of the number of rows matching the key and subtract that from my limit psuedo code: select count(*) from posts where searchTitle="Xbox" //returns 400 Then in Android I would have: limit = 500 numberToDelete = 500-queryCount //Gives me 100 the number of rows to delete SQL: DELETE FROM posts WHERE (SELECT * FROM posts where searchTitle="Xb (HowTos)