SQLite also has some other features for using SQL, such as finding the greatest id
from a column, and also the last insert and its id
, as shown in the following:
The INSERT
statement is the one used to add data into the database. However, the example to date has only shown data from fixed information or program variables. There is another way to insert data, which comes from another table based on the select criteria and data/column matching. This is an insert with a
subselect clause; see the following example:
SQLite> Insert into Salary values (Select id, name, salary from salary_import where name='Smith'); SQLite> Select * from Salary where name like '%smith%';
There are several variations available on the format, as shown in the preceding example. The SQL is flexible and there are options to select different data and offer computations on the last row of IDs.