In SQLite, we can use the TIME()
function to add a given number of seconds to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.
In SQLite, we can use the TIME()
function to add a given number of seconds to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.
In MySQL, the CASE
statement can be used in stored programs to perform a complex conditional construct. It compares a list of conditions and returns a different result depending on which condition (if any) is matched.
The CASE
statement is different to the CASE
operator, in that the CASE
statement is specifically for use in stored programs. Also, there’s a slight difference in the syntax.
Below are two options for removing duplicate rows from a table in PostgreSQL when those rows have a primary key or unique identifier column. The primary key is used in the query, but it’s ignored when comparing duplicates (due to the fact that primary keys prevent duplicate rows by definition).
The following examples delete duplicate rows but keep one. So in the case of say, three identical rows, it deletes two and keeps one.
Continue readingIn PostgreSQL, we can use the -
operator to subtract one or more hours from a time value.
By “time” value, this could be an actual time
value, a timestamp
, or an interval
. We can also subtract hours from a date
value or a date
and time
combination.
Below are two Oracle Database functions that convert uppercase characters to their lowercase equivalent.
Continue readingIn MySQL, the CASE
operator compares a list of conditions and returns one of multiple possible result expressions.
The CASE
expression is included in the SQL standard (ISO/IEC 9075), and most major RDBMSs support it.
MySQL also has the CASE
statement, which is slightly different to the CASE
operator. This article is about the CASE
operator.
Here are four options for returning rows that contain lowercase characters in PostgreSQL.
Continue readingIn MariaDB, we can use the CASE
operator to compare a list of conditions and return a different result depending on which condition (if any) is matched.
The CASE
expression is included in the SQL standard (ISO/IEC 9075), and most major RDBMSs support it.
MariaDB also has the CASE
statement, which is slightly different to the CASE
operator. This article is about the CASE
operator.
Below are examples of using some of the more popular RDBMSs to return the Unix timestamp.
The Unix timestamp (also known as Unix Epoch time, Unix time, or POSIX time) is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC).
Continue readingHere are two options for returning the number of days in a given month in SQLite. This could be the number of days in the current month, or it could be based on a given date.
Continue reading