B4J Question how combine two sql query

behnam_tr

Active Member
Licensed User
Longtime User
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
Longtime User
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime 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))
 
Upvote 0

behnam_tr

Active Member
Licensed User
Longtime User
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:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime 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.
 
Upvote 0

behnam_tr

Active Member
Licensed User
Longtime User
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 ;););)
 
Upvote 0
Top