If you’re using SQL Server’s GENERATE_SERIES()
function/relational operator and you’re getting an empty result set, then it could be due to one of the following reasons.
Tag: operators
Why GENERATE_SERIES() Only Returns the First Value in the Series in SQL Server
If you’re using the GENERATE_SERIES()
function to create a series of numbers, but you’re finding that only the first value in the series is returned, it could be something very obvious.
The obvious reason this could happen is that your step value is too big. In particular, if the step is so big that it covers the whole series, then it stands to reason that there will only be one value in the series.
If this is an issue for you, you might want to check that you’re using an appropriate step value. Using a smaller step value can help to create a series with more values.
Continue readingIntroduction to the GENERATE_SERIES() Function in SQL Server
In SQL Server, the GENERATE_SERIES()
function is a relational operator that returns a series of values between a given start and stop point. These are returned in a single-column table.
Although the GENERATE_SERIES()
function only works with numeric values, we can combine it with other functions to create a series of dates.
The GENERATE_SERIES()
function was introduced in SQL Server 2022 (16.x) and requires the compatibility level to be at least 160.
How the SQL UNION Operator Deals with NULL Values
The SQL UNION
operator concatenates the results of two queries into a single result set. By default it returns distinct rows (i.e. it removes any redundant duplicate rows from the result set). But we can also use UNION ALL
to return non-distinct rows (i.e. retain duplicates).
When it comes to NULL values, it’s pretty straight forward. SQL treats two NULL values as non distinct values. In other words, they’re duplicates.
Continue reading10 Functions and Operators that Search JSON Documents in MySQL
MySQL provides us with a bunch of functions and operators that allow us to search JSON documents for various things, such as specific values, paths, keys, etc.
Here are seven functions and three operators that search JSON documents in MySQL.
Continue readingUnderstanding the ->> Operator in MySQL
In MySQL, we can use the ->>
operator to extract a value from a JSON document, and unquote that value.
We provide the column that contains the JSON document to the left of the operator, and the path to the value that we want to extract to the right.
The ->>
operator is equivalent to JSON_UNQUOTE(JSON_EXTRACT())
, and it provides the same results.
Understanding the -> Operator in MySQL
In MySQL, we can use the ->
operator to extract data from a JSON document.
We provide the column that contains the JSON document to the left of the operator, and the path to the value that we want to extract to the right.
The ->
operator is an alias for the two-argument form of the JSON_EXTRACT()
function.
How the MEMBER OF() Operator Works in MySQL
In MySQL, the MEMBER OF()
operator tests whether or not a value is a member of a given JSON array.
It returns true (1
) if the array contains the value, and false (0
) if it doesn’t.
The MEMBER OF()
operator was added in MySQL 8.0.17.
SQLite CASE Expression
In SQLite, the CASE
expression compares a list of conditions and returns one of multiple possible expressions.
The CASE
expression is included in the SQL standard (ISO/IEC 9075), and most major RDBMSs support it.
PostgreSQL CASE Expression
In PostgreSQL, the CASE
expression 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.