I have an sqlite union query:
SELECT term,abstract, termid, nterm FROM
(SELECT term, subterm, termid, nterm FROM t1 WHERE (nterm like '%bayern%')
UNION
SELECT term, subterm, termid, nterm FROM t2 WHERE (subterm like '%bayern%')
) ORDER BY nterm+0 ASC
Now in the result set I get every word matched in nterm/subterm natural ordered. What I want though is to add a sort, that brings me first the matched in nterm and then in subterm (each ordered by natsort).
Is this possible? I tried to give a name to the queries in parenthesis (using AS t1, AS t2 respectively) but it returns me an error.
Here’s one way
If I get what you meant, easy to adapt anyway.
NB when you are doing select * From (somequery), you have to alias the query in the parentheses, otherwise the parser chokes on it.
This is a more verbose version of the above that makes what’s happening clearer