Search code examples
androidsqlitecounter

Sqlite next row acting strange Android


I have this query for moving in my database

Select data1,data2 From Table Where counter <"+somenumber+" and  order by counter DESC

this is for moving back, and i have same, but without desc for moving forward. The problem is that is going like this:68,69,70,7,71. Why is doing this? it goes to seven before 71.


Solution

  • As @Selvin suggested, change your counter column to hold Integer type and your order by will work properly.

    Or use the CAST operator:

    Select data1, data2 From Table
    Where CAST(counter as integer) < 10
    Order By CAST(counter AS INTEGER) DESC;