samedi 30 janvier 2016

Getting the nth record with where condition in Sqlite - Android [duplicate]

This question already has an answer here:

I have database that looks like this:

_id | isHistory | text  |
1   |   0       |   any |
2   |   0       |   txt |
3   |   1       |   he  |
4   |   1       |   re  |
5   |   0       |   sa  |
6   |   1       |   sa  |
7   |   0       |   rn  |

I am trying to get the 3rd record where the isHistory is 1:

_id | isHistory | text  |
3   |   1       |       |
4   |   1       |       |
6   |   1       |       | <- I want this

so it is the nth record where isHistory is 1

and the Nth record will be chosen by user, so it may be not existed in the table.

How can this be done with sqlite on Android ?

and How can I check if the Nth record is exists in the table with Where condition?

Aucun commentaire:

Enregistrer un commentaire