Fix “Parse error: all VALUES must have the same number of terms” in SQLite when using the VALUES Stand Alone Statement

If you’re getting an error that reads “Parse error: all VALUES must have the same number of terms” in SQLite when using the VALUES clause as a stand alone statement, it’s probably because you’re not providing the same number of columns in all rows.

When we use VALUES to create a constant table, we must provide the same number of columns in each row.

To fix this issue, be sure to provide the same number of columns across all rows.

Read more

Fix SQLite ‘Parse error: near “ORDER”‘ When Using VALUES as a Stand Alone Statement

If you’re getting an error that reads ‘Parse error: near “ORDER”‘ in SQLite, it could be that you’re trying to use the ORDER BY clause when using the VALUES clause as a stand alone statement.

Although we can certainly use the VALUES clause as a stand alone SQL statement, we can’t apply the ORDER BY clause against it.

However all is not lost. Below is an example of how we can sort the results of the VALUES statement.

Read more

SQLite CHANGES() Function

The SQLite changes() function returns the number of database rows that were changed, inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers.

Basically, it allows us to see how many rows are affected when we run any of those statements.

Read more

SQLite ABS() Explained

In SQLite, ABS() is a built-in scalar function that returns the absolute value of its argument.

The absolute value is the non-negative equivalent of the argument. It can be thought of as the distance from zero that the number resides on the number line, without considering direction.

Read more