sqlite查询,语句没错,却提示语法错误( near “Index“:syntax error)

发布时间:2024年01月19日

问题:

使用sql语句SELECT * FROM ChPoint WHERE Index>=1547 AND Index<=2306; 查询时,检查了好几遍语句也没发现有错误,试了 SELECT * FROM ChPoint WHERE Index?BETWEEN 1547 AND 2306;? 一样报错near "Index":syntax erro

解决方法:

经过坚持不懈的查询,终于发现Index是sqlite的保留关键字,如果字段中使用了Index,那么查询这个字段时不能直接使用,需要用中括号括起来再用,比如此处语句写为以下方式就不会再报错:

SELECT * FROM ChPoint WHERE [Index] BETWEEN 1547 AND 2306;? 或者

SELECT * FROM ChPoint WHERE [Index]>=1547 AND [Index]<=2306;

sqlite保留字搜集

ABORT CREATE FROM NATURAL ROLLBACK ACTION CROSS
FULL NO ROW ADD CURRENT_DATE GLOB NOT SAVEPOINT
CURRENT_TIME GROUP SELECT ALL CURRENT_TIMESTAMP
HAVING NULL SET ALTER DATABASE IF OF TABLE ANALYZE
DEFAULT IGNORE OFFSET TEMP AND DEFERRABLE IMMEDIATE
ON TEMPORARY AS DEFERRED IN OR THEN ASC DELETE INDEX
ORDER TO ATTACH DESC INDEXED OUTER TRANSACTION?
AUTOINCREMENT DETACH INITIALLY TRIGGER BEFORE DISTINCT?
INNER PRAGMA UNION BEGIN DROP INSERT PRIMARY UNIQUE UPDATE?
QUERY INSTEAD EACH BETWEEN BY ELSE INTERSECT RAISE USING?
VACUUM RECURSIVE INTO END CASCADE CASE ESCAPE IS?
REFERENCES VALUES VIEW REGEXP ISNULL EXCEPT CAST CHECK?
EXCLUSIVE JOIN REINDEX VIRTUAL WHEN RELEASE KEY EXISTS?
COLLATE COLUMN EXPLAIN LEFT RENAME WHERE WITH LIKE FAIL?
COMMIT CONFLICT FOR LIMIT RESTRICT WITHOUT RIGHT MATCH?
FOREIGN CONSTRAINT

文章来源:https://blog.csdn.net/lvyiwuhen/article/details/135696159
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。