I want to insert rows if nothing exists in a table.
Something like that:
WHEN NOT EXISTS (SELECT * FROM Students) THEN
INSERT INTO Students (name) VALUES ("Foo Bar"), ("Bar Foo")
But it causes Error: SQLITE_ERROR: near "WHEN": syntax error
I want to insert rows if nothing exists in a table.
Something like that:
WHEN NOT EXISTS (SELECT * FROM Students) THEN
INSERT INTO Students (name) VALUES ("Foo Bar"), ("Bar Foo")
But it causes Error: SQLITE_ERROR: near "WHEN": syntax error
You could use:
INSERT INTO Students (name)
SELECT * FROM (VALUES ("Foo Bar"), ("Bar Foo"))
WHERE NOT EXISTS(SELECT * FROM Students);