vendredi 22 janvier 2016

How to sort SQLite table result in specific order?

I have a table in my sqlite database, i need to sort it in this way..

 '467958X1010X49611' 
 '467958X1010X49612' 
 '467958X1010X49613' 
 '467958X1010X49614' 
 '467958X1010X49615' 
 '467958X1010X49616' 
 '467958X1010X49617' 
 '467958X1010X49618' 
 '467958X1010X49619' 
 '467958X1010X496110' 
 '467958X1010X4961other' 

but i am getting this.

 '467958X1010X4961other' 
 '467958X1010X49611' 
 '467958X1010X49612' 
 '467958X1010X49613' 
 '467958X1010X49614' 
 '467958X1010X49615' 
 '467958X1010X49616' 
 '467958X1010X49617' 
 '467958X1010X49618' 
 '467958X1010X49619' 
 '467958X1010X496110' 

my code is.

cursor = db.query(TABLE_SGQ_LIVE, new String[] {SGQ},
                    null, null, null, null, Q_Id + " ASC, " + G_id  + " ASC");


// where '467958X1010X496110' 'X' is the separator of SID,G_id,Q_ID.
// and Q_Id ,G_id are fields in table.

I think it is enough to understand the problem. I mean sorting (integer first and string second). Thanks

Aucun commentaire:

Enregistrer un commentaire