SQLITE_ERROR] incomplete input by using union all

Viewed 4929

I get the following error if I want to put these table rows together

[SQLITE_ERROR] SQL error or missing database (incomplete input)

each one works individually.

SELECT x.ActionListId, x.wordindexed, x.word, x.wordreplacement
from Words x
where x.wordindexed like "%Hallo %" 
limit 1
    union all
SELECT p.ActionListId, p.wordindexed, p.word, p.wordreplacement
from Words p
where p.word like "%Tool%"
limit 1;
1 Answers

One option here is to wrap your current subqueries, and then take the union of that:

SELECT ActionListId, wordindexed, word, wordreplacement
FROM
(
    SELECT *
    FROM Words
    WHERE wordindexed LIKE "%Hallo %"
    LIMIT 1
) t1
UNION ALL
SELECT ActionListId, wordindexed, word, wordreplacement
FROM
(
    SELECT *
    FROM Words
    WHERE wordindexed LIKE "%Tool %"
    LIMIT 1
) t2;

Here is a demo link showing that this syntax works:

Demo

Related