I have a database that is updated with datasets from time to time. Here it may happen that a dataset is delivered that already exists in database.
Currently I'm first doing a
SELECT FROM ... WHERE val1=... AND val2=...
You can do that with a single statement and a subquery in nearly all relational databases.
INSERT INTO targetTable(field1) SELECT field1 FROM myTable WHERE NOT(field1 IN (SELECT field1 FROM targetTable))
Certain relational databases have improved syntax for the above, since what you describe is a fairly common task. SQL Server has a
MERGE syntax with all kinds of options, and MySQL has optional
INSERT OR IGNORE syntax.
Edit: SmallSQL's documentation is fairly sparse as to which parts of the SQL standard it implements. It may not implement subqueries, and as such you may be unable to follow the advice above, or anywhere else, if you need to stick with SmallSQL.