Android Question SQL Order + Where

parijs

Active Member
Licensed User
Longtime User
What am I doing wrong ?

Code: Copy
oRst = SQL.ExecQuery2("SELECT * FROM Bustrip ORDER BY sort Asc WHERE bus = ?", Array As String (Main.find))
 
Oke but whats wrong now? ;)

Code: Copy
oRst = SQL.ExecQuery2("SELECT * FROM Bustrip WHERE bus = ?", Array As String (Main.find) ORDER BY sort Asc)
 
Upvote 0
Oke but whats wrong now? ;)

Code: Copy
oRst = SQL.ExecQuery2("SELECT * FROM Bustrip WHERE bus = ?", Array As String (Main.find) ORDER BY sort Asc)
Code: Copy
oRst = SQL.ExecQuery2("SELECT * FROM Bustrip WHERE bus = ? ORDER BY sort Asc", ArrayAsString (Main.find) )
By the way, [sort] is a field? If not, place the field you want instead of it.
 
Upvote 0
Hi, if bustrip is a string then the sort order is correct, if bustrip is always a number then define it as a int/long etc.
 
Upvote 0
parijs says: I changed it to int and works
Please note that you did not have to change the field data type from TEXT to INTEGER to get the proper sort.
If you have a field named Sort that is of TEXT type in a table, but contains all integers, you do not have to change the field data type in the table to INTEGER. You can always sort using the CAST function like this: ORDER BY CAST(Sort AS INTEGER). The records will be sorted properly.
 
Upvote 0

Similar Threads

  • Question Question
Android Question SQL ORDER BY
Replies
18
Views
7K
Replies
108
Views
102K
Replies
1
Views
3K
  • Locked
  • Article Article
Android Tutorial SQL tutorial
Replies
161
Views
337K
Back
Top