B4J Question how combine two sql query

behnam_tr

Member
hi

i want to combine two sql query

B4X:
Dim RS As ResultSet=Sql1.ExecQuery2("SELECT * FROM tbl WHERE userid = ? ", Array As Int(uid))
    Dim RS As ResultSet=Sql1.ExecQuery2("SELECT * FROM tbl OFFSET LIMIT ?,?",Array As String(0,10))
how do i this ??
 

jmon

Well-Known Member
Licensed User

jmon

Well-Known Member
Licensed User
How about that? That selects 10 rows where the column userid = uid
B4X:
Dim s As String = $"
SELECT * FROM tbl WHERE userid = ? LIMIT ?;"$
Dim RS As ResultSet=Sql1.ExecQuery2(s, Array (uid,10))
 

behnam_tr

Member
i check this but it select all rows

B4X:
    Dim s As String = $"
SELECT * FROM hesabdari WHERE userid = ?
UNION
SELECT * FROM hesabdari OFFSET LIMIT ?,?"$
    Dim RS As ResultSet=Sql1.ExecQuery2(s, Array (uid, counter,19))
first shuold i select all row where uid=x
then i want to select 0-10 rows or x-y row from rows that fetched from first step
maybe first step return 50 rows i want select 0-10 records or 10-20 records (start pos- end pos)
ok ??
 
Last edited:

DonManfred

Expert
Licensed User
but i want select rows 0-10 or 10-15 or x-y with offset where uid=x
use LIMIT

LIMIT 0,10 (0 to 9)
LIMIT 9,5 (10 to 15)

something like
B4X:
Dim s As String = $"
SELECT * FROM tbl WHERE uid = ? LIMIT ?,?;"$
Dim RS As ResultSet=Sql1.ExecQuery2(s, Array (uid,9,5))
I strongly suggest to learn the SQL Language basics.
 

behnam_tr

Member
use LIMIT

LIMIT 0,10 (0 to 9)
LIMIT 9,5 (10 to 15)

something like
B4X:
Dim s As String = $"
SELECT * FROM tbl WHERE uid = ? LIMIT ?,?;"$
Dim RS As ResultSet=Sql1.ExecQuery2(s, Array (uid,9,5))
I strongly suggest to learn the SQL Language basics.

thanks guys
solved with this ;););)
 
Top