The following examples return only those rows that don’t contain any numeric digits in a given column in Oracle Database.
Continue readingAuthor: Ian
2 Ways to Return the Unix Timestamp in SQLite
The unix timestamp is the number of seconds since 1970-01-01 00:00:00 UTC. SQLite provides us with a couple of ways to get the unix timestamp.
Continue readingFix “ERROR: each INTERSECT query must have the same number of columns” in PostgreSQL
When using PostgreSQL’s INTERSECT
operator, if you encounter an error that reads “ERROR: each INTERSECT query must have the same number of columns“, it’s because there’s a mismatch in the number of columns returned by the queries on either side of the INTERSECT
operator.
The way to fix this is to ensure that both SELECT
statements return the same number of columns.
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.
2 Ways to Delete Duplicate Rows in MariaDB (Ignores Primary Key)
Here are examples of removing duplicate rows from a table in MariaDB when those rows have a primary key or unique identifier column.
The examples delete duplicate rows but keep one. So in the case of two identical rows, it deletes one of them and keeps the other.
Continue readingFix “ERROR 1222 (21000): The used SELECT statements have a different number of columns” when using UNION in MySQL
If you’re getting “ERROR 1222 (21000): The used SELECT statements have a different number of columns” when using the UNION
clause in a MySQL query, it’s probably because the number of columns returned by each SELECT
statement is different.
Get the First Monday of a Month in SQLite
SQLite’s DATE()
function provides us with the ability to return the date of the first instance of a given day of a given month. Therefore, we can use it to return the first Monday of a given month. We can also use it to return the first Tuesday, Wednesday, Thursday, Friday, etc.
We can use DATETIME()
if we want a datetime value to be returned.
Get the Date/Time from a Unix Timestamp in SQLite
If you have a Unix timestamp, you can use SQLite’s DATETIME()
function with the unixepoch
modifier to compute the actual date and time.
You can alternatively use the DATE()
function if you only need the date to be returned. And it’s also possible to use the TIME()
function to return just the time portion.
Add Months to a Date in PostgreSQL
In PostgreSQL, we can use the +
operator to add one or more months to a date. There are several options when it comes to specifying the actual number of months.
3 Ways to Find Rows that Contain Uppercase Letters in MySQL
Here are three options for returning rows that contain uppercase characters in MySQL.
Continue reading