Android Question Get multiple JdbcResultSet in a single ExecQuery2

netsistemas

Active Member
Licensed User
Longtime User
can i do something sql="select * from table1 ; Select * from table2"
in only one ExecQuery?

(like vb60, vb.net, php and other)




Multi - Recordset/ResultSet

B4X:
Dim Cursor As JdbcResultSet
Cursor = SQL1.ExecQuery("SELECT col1, col2 FROM table1")
Do While Cursor.NextRow
    Log(Cursor.GetString("col1"))
    Log(Cursor.GetInt("col2"))
Loop
 

DonManfred

Expert
Licensed User
Longtime User
Inform about INNER JOIN, LEFT JOIN.
See SQL-Tutorials.

In short the answer is NO. You can not use two queries in one call.

But you can use JOIN to get Values from different tables in one call.

Asuming you are using MySQL

SQLite

Once you understand how they are working a new world of possibilities appears
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Multi - Recordset/ResultSet
i havn´t seen a B4X implementation of this.
Even not a JDBC-Version of them.

But as written in my 1st answer you can use JOINs to get Values from another table too if they are related to eachother and you can reference them.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
INNER JOIN, LEFT JOIN.
and UNION.

Example:
B4X:
Cursor = SQL1.ExecQuery("SELECT 'table1' AS tbl, col1, col2 FROM table1 UNION SELECT 'table2' AS tbl, col1, col2 FROM table2")
Do While Cursor.NextRow
    Log(Cursor.GetString("tbl"))
    Log(Cursor.GetString("col1"))
    Log(Cursor.GetInt("col2"))
Loop
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
I already assumed not, but the truth is that it is something that I have discovered that can be done recently (and look, I have been doing this for years) in other languages, even vb60 with recordset!! And just in case, I asked.
Thanks for the response.
 
Upvote 0
Top