SQLite is a database and not a programming language, so the declarative language you have in it allows something similar that is the select
you already know. for each
is typically imperative.
You can extend SQLite to accept other things. It is open source and even has some facilities to include customizations. Then you could create a sort of stored procedure or SQL extension contained in it. Of course, it's not something simple to do. It could be in C, a language of its own, a change of standard SQL or other language, such as Lua, C #, or other already known, each with its advantages and disadvantages.
So it's easier to query easily and then manipulate the application. That's why understanding everything you can do in a query can help you filter out just what you want. I see lots of bad queries on codes out there, including from experienced people. In part because the SQL query model does not help, so many go to NoSQL, but often for the wrong reasons.
Having said all this it is possible to make a insert
based on a select
, that is, the data source of insert
can be the result of a select
. As the question does not say what it needs, I could not help it anymore. Example:
INSERT INTO b (meuX) VALUES (x)
SELECT x FROM a;