SQLite SUBSTRING() Explained

In SQLite, substring() is an alias for substr().

It returns a substring from a string, based on a given starting location within the string. Two arguments are required, and a third optional argument is accepted.

The substring() naming was introduced in SQLite 3.34.0, which was released on 1st December 2020. The reason that the substring() syntax was introduced was for compatibility with SQL Server.

Read more

SQLite Renames PRINTF() to FORMAT()

SQLite has introduced the FORMAT() function, which can be used to format strings.

More precisely, it has actually just renamed its SQL PRINTF() function to FORMAT(). The reason is for better compatibility with other DBMSs. The original PRINTF() name is retained as an alias for backwards compatibility.

The FORMAT() function (or its naming) was introduced in SQLite 3.38.0, which was released on 22 February 2022.

Read more

SQLite SHOW TABLES Equivalent

SQLite doesn’t have a SHOW TABLES statement like MySQL and MariaDB have, but it does have a similar command.

In SQLite, you can use the .tables command to show a list of tables. You can alternatively use the table_list pragma to do the job.

Read more

VALUES Clause in SQL Server

In SQL Server, VALUES is a table value constructor that specifies a set of row value expressions to be constructed into a table.

The VALUES clause is often used with INSERT statements to insert data, but it can also be used as a derived table in either the USING clause of the MERGE statement or the FROM clause.

Read more

PostgreSQL DATEADD() Equivalent

Updated 20 April 2024 to include the date_add() function.

SQL Server has its DATEADD() function that adds an interval to a date value. MySQL’s DATE_ADD() and ADDDATE() for does the same thing, as does MariaDB’s DATE_ADD() and ADDDATE(). SQLite has a DATE() function that also provides the option of adding an interval to a given date.

Prior to version 16, PostgreSQL didn’t have a DATEADD() or equivalent function. But with PostgreSQL 16 came with the introduction of the date_add() function, which allows us to add an interval to a timestamp with time zone.

We can also add and subtract values from dates with date/time operators such as + and -.

Read more

SQLite INTERSECT Operator

In SQLite, the INTERSECT operator is used to create a compound SELECT statement that returns the intersection of the results of the left and right SELECT statements. In other words, it combines two queries, but returns only those rows that are returned in both queries.

Read more