netsistemas Active Member Licensed User Longtime User Mar 5, 2025 #1 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: Copy 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
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: Copy 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 Mar 5, 2025 #2 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 MySQL Joins The JOIN clause is used to combine rows from two or more tables, based on a related column between them. www.w3schools.com SQLite A Visual Explanation of SQLite Joins In this tutorial, you will learn about various kinds of SQLite joins to query data from two or more tables. www.sqlitetutorial.net Once you understand how they are working a new world of possibilities appears Upvote 0
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 MySQL Joins The JOIN clause is used to combine rows from two or more tables, based on a related column between them. www.w3schools.com SQLite A Visual Explanation of SQLite Joins In this tutorial, you will learn about various kinds of SQLite joins to query data from two or more tables. www.sqlitetutorial.net Once you understand how they are working a new world of possibilities appears
DonManfred Expert Licensed User Longtime User Mar 5, 2025 #3 netsistemas said: Multi - Recordset/ResultSet Click to expand... 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
netsistemas said: Multi - Recordset/ResultSet Click to expand... 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.
aeric Expert Licensed User Longtime User Mar 5, 2025 #4 DonManfred said: INNER JOIN, LEFT JOIN. Click to expand... and UNION. Example: B4X: Copy 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
DonManfred said: INNER JOIN, LEFT JOIN. Click to expand... and UNION. Example: B4X: Copy 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
DonManfred Expert Licensed User Longtime User Mar 5, 2025 #5 aeric said: and UNION Click to expand... Yes, UNION is another way Upvote 0
netsistemas Active Member Licensed User Longtime User Mar 5, 2025 #6 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
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.