Gilles Roy
|
Re: QDB - how to retrieve row number of result row!
|
Gilles Roy
02/07/2010 9:46 PM
post46737
|
Re: QDB - how to retrieve row number of result row!
> thanks for your answer. Is there any chance to get this id, which is shown at
> a SELECT at the beginning of a row (0001,0002,...)?
>
> The background is, i SELECT over 3 tables and UNION them. Now i need an
> identifier which is increasing over all three SELECT statements, to be able to
> SELECT exactly one result of those 3 UNION SELECTS. Is there a way, to
> perform such a operation?
Hi Florian,
Say I wanted the 10th to 15th results from a union of other results. What I would try is:
select id from (select ... union ... select ... etc) LIMIT 5 OFFSET 10;
(fetch 5 results starting at offset 10)
I'm not sure I fully understand what you need to accomplish, I hope this helps.
Regards,
Gilles
|
|
|
Ryan Allen(deleted)
|
Re: QDB - how to retrieve row number of result row!
|
Ryan Allen(deleted)
02/07/2010 9:59 PM
post46738
|
Re: QDB - how to retrieve row number of result row!
It sounds like you're just looking for the loop counter that qdbc prints when looping through the result rows. It's not
a number that's stored in the database, or in the result.
The code (in services/qdb/lib/qdb.c:qdb_printmsg()) is:
496 for (row = 0; row < nrows; ++row) {
497 fprintf(fp, "%05d:\t", row);
You cannot use that specific number to refer to a row in a table; you can use it to refer to an offset in a query (with
something like the OFFSET keyword as Gilles mentioned), but that might not be what you want. (For example, if rows are
added/changed/deleted that would modify your result set the offset into that result will change.)
|
|
|
Dan Cardamore(deleted)
|
Re: QDB - how to retrieve row number of result row!
|
Dan Cardamore(deleted)
02/08/2010 7:50 AM
post46764
|
Re: QDB - how to retrieve row number of result row!
I think a better location to get this answer would be the sqlite.org forums. I think what you're looking for can't be
done with sqlite the way it is now.
Dan
On 2010-02-05, at 2:35 AM, Florian Becher wrote:
> Hi Dan,
>
> thanks for your answer. Is there any chance to get this id, which is shown at a SELECT at the beginning of a row (0001
,0002,...)?
>
> The background is, i SELECT over 3 tables and UNION them. Now i need an identifier which is increasing over all three
SELECT statements, to be able to SELECT exactly one result of those 3 UNION SELECTS. Is there a way, to perform such a
operation?
>
> Thanks in advance for your help,
>
> Florian
>
>
>
> _______________________________________________
>
> Development
> http://community.qnx.com/sf/go/post46621
>
>
Dan Cardamore
dcardamore@qnx.com
|
|
|