如果表中不存在行,我想插入行。
类似的东西:
WHEN NOT EXISTS (SELECT * FROM Students) THEN
INSERT INTO Students (name) VALUES ("Foo Bar"), ("Bar Foo")
但这会导致Error: SQLITE_ERROR: near "WHEN": syntax error
答案 0 :(得分:-1)
您可以使用:
INSERT INTO Students (name)
SELECT * FROM (VALUES ("Foo Bar"), ("Bar Foo"))
WHERE NOT EXISTS(SELECT * FROM Students);