Android Question "merging" sql selections

DPaul

Active Member
Licensed User
Longtime User
Hi,

Don't know what to call it but this is what i would like to do:
In one sub, i have two different calls to an sql database like:

(x and y are strings)
(sel1 and 2 are cursors)
sel1 = SQLdata.ExecQuery(x)
sel2 = SQLdata.ExecQuery(y)

obviously both return the same fields (select * from...) but different records.

Is it possible to "add or merge" the result of sel1 and sel2 into a new "sel3"...?

thx,
Paul
 
Last edited:
Upvote 0
Thanks, this is ALMOST what i am looking for.
Imagine that what i find in selection 1 determines what i will be asking in selection 2.
So i cannot do it in one "UNION" statement.

I have 2 separate result datasets (cursors) and i want to "Attach or Union, or Merge..." them.

Maybe it cannot be done.

Paul
 
Upvote 0
Hi,

Don't know what to call it but this is what i would like to do:
In one sub, i have two different calls to an sql database like:

(x and y are strings)
(sel1 and 2 are cursors)
sel1 = SQLdata.ExecQuery(x)
sel2 = SQLdata.ExecQuery(y)

obviously both return the same fields (select * from...) but different records.

Is it possible to "add or merge" the result of sel1 and sel2 into a new "sel3"...?

thx,
Paul

try this:

Code: Copy
sel3 = SQLdata.ExecQuery(x & " union all " & y)

RBS
 
Upvote 0
Thanks, but i do not know what y will look like, until i executed and examined x!

I can always create an empty copy of my database, and copy all the cursors into that.

Merging 2 cursors would have been more elegant and shorter.

Paul
 
Upvote 0
Thanks, but i do not know what y will look like, until i executed and examined x!

I can always create an empty copy of my database, and copy all the cursors into that.

Merging 2 cursors would have been more elegant and shorter.

Paul

OK, then run SQL x, examine the resulting cursor, construct SQL y and then run:

Code: Copy
sel3 = SQLdata.ExecQuery(x & " union all " & y)

Don't know what your data is and what you are doing, but maybe you can do it all in one SQL
with the right where conditions and/or joins.

RBS
 
Upvote 0
Don't know what your data is and what you are doing, but maybe you can do it all in one SQL
with the right where conditions and/or joins.
This. You (the original poster) have not really given us enough information to determine if SQL can handle your request. What determines the appropriate “x” that “y” depends upon? Technically, @DonManfred answered you original question, but then you changed the goal post without going into specifics. That y depends on x is not specific.
 
Upvote 0
obviously both return the same fields (select * from...) but different records.
There is not enough data to understand the queries but if possible
make the queries work together as one query -
select * from... WHERE [condition for x] OR [condition for y]
 
Upvote 0
Hi Guys,

I appreciate your inputs, but i try to make my questions as simple as possible.
Just enough information to answer the question.
The original question is: "can i merge the contents of 2 different cursors (obviously with the same fields)" ?
I was looking for something straightforward like cursor1.append (......).....

The answer is : no (or nobody knows)

Doing the union is appealing, but not if i want to merge/append 3 cursors,
which is ultimately the same question as doing 2.

Workarounds, I can think of many. But they all have more lines of code than "cursor.append(...)"

So don't hesitate to say "no, that is not possible". If that means I'm stuck, i'll post another question :-)

Paul
 
Upvote 0

Similar Threads

Back
Top