Android Question Concatenation of two field names in query

Pahbie

Member
Licensed User
Longtime User
Apologies if asked already.

i am trying to display the first and last names from a table and cannot figure out how to concatenate the two fields in a query
Prolly very simple but I am stumped!

I tried getstring but cannot seem to be able to concatenate both firstname and lastname. i've tried the & and + operators to no avail.
 

klaus

Expert
Licensed User
Longtime User
For SQLite you may have a look HERE.
Instead of using this:
B4X:
Query = "SELECT FirstName, LastName, City FROM persons"
ResultSet1.GetString("FirstName") & "  /  " & ResultSet1.GetString("LastName")

You could use this:
B4X:
Query = "SELECT FirstName || '  /  ' || LastName As FullName"
ResultSet1.GetString("FullName")
Do not worry about the colors above. The single quotes are not a comment.
 
Upvote 1

Pahbie

Member
Licensed User
Longtime User
Here is my code:

pm.Initialize(Activity)

cur = Starter.sql.ExecQuery("select * from person")

cur.position=0

Activity.Title=cur.GetString("lstname")
-----------------------------------
I can not display the lastname from the SELECT query but no more. i cannot figure out how to combine the use of the FIRSTNAME field in the query or the output
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
What are the field names in the database table? It would make it easier for people to answer with a proper example if they knew the names.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You need to give more details on what exactly you want to do.
Why do you use ?
B4X:
cur = Starter.sql.ExecQuery("select * from person")

And not ?
B4X:
curs = Starter.sql.ExecQuery("SELECT FirstName || '  /  ' || LastName As FullName from person"
You must, of course, adapt the column names and the table name to your application.

Or, as already suggested, post your project or better a small project showing the problem.
So we can see what you have done and how.
 
Upvote 0
Top