On 3 Oct 2017, at 11:13pm, Doug Nebeker <ad...@poweradmin.com> wrote:

> How can I select a document and get the complete sorted text back in a single 
> row (so I can do a JOIN on a different table with additional information)?  

There is a way which will probably work but the documentation adds a careful 
note that it will not always work.

<https://sqlite.org/lang_aggfunc.html#groupconcat>

So you would want something like

SELECT group_concat(LineText, '\n') FROM
        (SELECT LineText FROM DocLines
                WHERE DocID = 10
                ORDER BY LineIndex)

The problem is that the order of concatenation is arbitrary, in other words you 
shouldn’t rely on this working.

If you don’t want to use group_concat(), do it in your programming language.  
Use

SELECT LineText FROM DocLines
                WHERE DocID = 10
                ORDER BY LineIndex

and concatenate the retrieved values in your programming language.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to