I'd just sort the data into the order I wanted the result set presented in 
using an ORDER BY clause on the SELECT which retrieves the data ...

> > On Oct 15, 2016, at 11:12 AM, Keith Medcalf <kmedc...@dessus.com> wrote:
> >
> >> Is there a way to do this automagically (like a specialized INSERT
> >> command?) in Sqlite?
> >
> > Unfortunately no, there is no way to do this on *ANY* database that uses
> the relational database model.
> There’s no need to dive into database theory! I’ll play devil’s advocate
> and say that this could pretty easily be done in SQLite by writing a
> simple extension function like in inbetween(a, b) that takes two strings
> and returns a string that sorts in between them, as I described
> previously.
> Then you just make the table’s primary key a string and do
>       INSERT INTO mytable (ID, …) VALUES (inbetween($firstid, $secondid),
> …)
> where $firstid and $secondid are the the primary keys of the two rows you
> want to insert between.
> In real life you’d probably just implement inbetween() as part of your
> program instead of as a SQLite function; I just wanted to prove that a
> relational database can in fact do this.
> —Jens

sqlite-users mailing list

Reply via email to