为什么在SQLite3中不能执行SELECT查询?

时间:2019-07-17 16:33:51

标签: sqlite

插入:

INSERT INTO MATCHES ("url", "league", "home_team", "away_team", "current_time", "current_score", "penalty_not_score_team", "penalty_not_score_time", "penalty_not_score_name") 
VALUES ('https://www.myscore.com.ua/match/8nsN4E4k/#match-summary', 'АРГЕНТИНА: Кубок Аргентины - 1/16', 'Химнасия Мендоса', 'Ривер Плейт', 'Послес.п.', '1 - 2', 'home', '4''', 'Andrada B.')

结果:

Result: query completed successfully
At line 1:
INSERT INTO MATCHES ("url", "league", "home_team", "away_team", "current_time", "current_score", "penalty_not_score_team", "penalty_not_score_time", "penalty_not_score_name") 
VALUES ('https://www.myscore.com.ua/match/8nsN4E4k/#match-s...', 'АРГЕНТИНА: Кубок Аргентины - 1/16', 'Химнасия Мендоса', 'Ривер Плейт', 'Послес.п.', '1 - 2', 'home', '4''', 'Andrada B.')

选择:

SELECT * 
FROM MATCHES 
WHERE (url="https://www.myscore.com.ua/match/8nsN4E4k/#match-summary" AND league="АРГЕНТИНА: Кубок Аргентины - 1/16" AND home_team="Химнасия Мендоса" AND away_team="Ривер Плейт" AND current_time="Послес.п." AND current_score="1 - 2" AND penalty_not_score_team="home" AND penalty_not_score_time="4'" AND penalty_not_score_name="Andrada B.")

结果:

Result: 0 rows returned in 1ms
At line 1:
SELECT * 
FROM MATCHES 
WHERE (url="https://www.myscore.com.ua/match/8nsN4E4k/#match-s..." AND league="АРГЕНТИНА: Кубок Аргентины - 1/16" AND home_team="Химнасия Мендоса" AND away_team="Ривер Плейт" AND current_time="Послес.п." AND current_score="1 - 2" AND penalty_not_score_team="home" AND penalty_not_score_time="4'" AND penalty_not_score_name="Andrada B.")

数据库中的记录是100%,我用DB Browser for SQLite3观看了 我尝试了不同的语法-无济于事。 简短查询有效,但我需要对所有项目进行抽样。

1 个答案:

答案 0 :(得分:1)

您必须引述current_time,否则将其视为函数调用SELECT current_time

AND current_time="Послес.п."
=>
AND "current_time"='Послес.п.'

db<>fiddle demo

CREATE TABLE t(current_time CHAR(10));
INSERT INTO t(current_time) VALUES('aaa');
-- 1 row
SELECT * FROM t;

-- 0 rows returned
SELECT *
FROM t
WHERE current_time = 'aaa';

-- 1 row returned
SELECT *
FROM t
WHERE "current_time" = 'aaa';