Android Question Select SQL with Order

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,
I am trying to Log items from a SQL database like below:

(This is how my app is loading each item at the minute, but need a way to alphabetically load the names)
B4X:
For i = 1 To 10
  If SQL1.ExecQuerySingleResult("SELECT light" & i & " FROM names WHERE id = 1") = "" Then
      ' do nothing as the database has no name in the field
  Else
      ' log item here
  End If
Next
My Database looks like this:

sql_list.png



The question I have is I now want to display the items alphabetically.

As you can see I have Zones and Lights in the database (same table in the database) and I only want to log the lights alphabetically.
Not all lights may have names, so I don't want to display them if they don't have names.

However, I want to be able to log the name that is in the database with which item it is from.

For Example:
light1 = Tom
light2 = Aaron
light3 = (no name, so don't log it)
light4 = Billy

So the log would looks like this:
Aaron - 2
Billy- 4
Tom - 1

Any one have any suggestions on how I can do this ?
 
Top