换行符在sqlLite中有特殊含义吗?我缺少数据库(“ SELECT”附近:语法错误)

时间:2018-11-16 19:48:03

标签: sqlite newline

如果我删除换行符,我突然会收到错误消息。

缺少数据库(“ SELECT”附近:语法错误)

没有新行,在sqlite中不起作用-是否有错误? Jetbrains IDE有问题吗?

如果我将选择范围缩短了,那么我也没有错误了。

此选择给出错误:

  

SELECT * FROM(从单词索引为LIKE'gt%'且ActionListID = 1的单词从ROWID asc LIMIT 10顺序中选择单词,从单词中选择不同的单词,单词说明,单词替换)*从FROM单词中选择不同的单词,单词说明,单词替换单词索引的GLOB'%gt%'和ActionListID = 1的行,按ROWID desc LIMIT 10排序)t3 UNION ALL SELECT * FROM(从单词索引为'%gt%'和ActionListID = 1 LIMIT 2的单词中选择不同的单词,单词描述,单词替换) t4 SELECT * FROM(从单词索引像'gt%'LIMIT 2的单词中选择不同的单词,单词描述,单词替换)t5 SELECT * FROM(从单词索引像'%gt%'LIMIT 2的单词中选择不同单词,单词描述,单词替换)t6限制10;

与所有新行相同,并且没有错误:

SELECT * FROM (
SELECT distinct word, worddescription, wordreplacement
     FROM Words
     WHERE wordindexed LIKE 's%'
     and   ActionListID > 0
     order by ROWID asc
     LIMIT 10
     ) t2
UNION ALL
SELECT *
...

对不起,我不得不将其放在外面,因为此Web GUI表面不允许这样做。 https://gist.github.com/sl5net/731c5ef0cd7c68dbddc86bc26cc5838f

enter image description here enter image description here enter image description here

我正在使用:

IntelliJ IDEA 2018.2.5(最终版) JRE:1.8.0_152-release-1248-b19 amd64 JVM:JetBrains s.r.o的OpenJDK 64位服务器VM Windows 10 10.0

1 个答案:

答案 0 :(得分:0)

T4t5子选择之后,您就错过了UNION ALL

也不需要为UNION使用子选择。您可以直接使用这些名称代替SELECT * FROM

SELECT * FROM (
    SELECT distinct word, worddescription, wordreplacement
    FROM Words
    WHERE wordindexed LIKE 'gt%' and ActionListID = 1
    order by ROWID asc
    LIMIT 10

    UNION ALL

    SELECT distinct word, worddescription, wordreplacement
    FROM Words
    WHERE wordindexed GLOB '%gt%' and ActionListID = 1
    order by ROWID desc
    LIMIT 10

    UNION ALL

    SELECT distinct word, worddescription, wordreplacement
    FROM Words
    WHERE wordindexed like '%gt%' and ActionListID = 1
    LIMIT 2

    UNION ALL

    SELECT distinct word, worddescription, wordreplacement
    FROM Words
    WHERE wordindexed like 'gt%'
    LIMIT 2

    UNION ALL

    SELECT distinct word, worddescription, wordreplacement
    FROM Words
    WHERE wordindexed like '%gt%' LIMIT 2
) limit 10;

相反,请使用包含所有联合选择的SELECT来执行最后一个limit 10