I suppose I'm doing something of wrong but this i the problem:
StoDate is a text field and represent a date in the format "2016-02-01 12:54:00"
If I use this code
I obtain the expected result, the most recent record
>>> 2587 - 2016-01-27 08:50:30
If I use this code instead
I obtain the oldest record
*** 2587 - 2016-01-07 06:46:59
In other words the "order by" clause is ignored
Where is my fault ?
StoDate is a text field and represent a date in the format "2016-02-01 12:54:00"
If I use this code
B4X:
Dim rs As ResultSet = MySub.SQL_Bls1.ExecQuery("SELECT * FROM records WHERE V_ID = 2587 ORDER BY StoDate DESC LIMIT 1")
Do While rs.NextRow
Log(">>> " & rs.GetString("v_id") & " - " & rs.GetString("StoDate"))
Loop
I obtain the expected result, the most recent record
>>> 2587 - 2016-01-27 08:50:30
If I use this code instead
B4X:
Dim rs As ResultSet=MySub.SQL_Bls1.ExecQuery2("SELECT * FROM records WHERE V_ID = ? ORDER BY ? DESC LIMIT 1", Array("2587", "StoDate"))
Do While rs.NextRow
Log("*** " & rs.GetString("v_id") & " - " & rs.GetString("StoDate"))
Loop
I obtain the oldest record
*** 2587 - 2016-01-07 06:46:59
In other words the "order by" clause is ignored
Where is my fault ?