SQLite Forum

UNION Sorts on First Field
Login
If there is no ORDER BY clause, the SQL engine (*any* SQL engine, not just SQLite)
is free to return the rows in any order it wants.  That order might change from
one update of the database engine to the next, or from one database to the next,
or even on two consecutive runs of the same query.

If you need a particular output order, then you *must* use an ORDER BY clause.