Understanding 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.

Read more

How JSON_OVERLAPS() Works in MySQL

In MySQL, JSON_OVERLAPS() is a function that tests whether or not two JSON documents have any key-value pairs or array elements in common.

The function returns true (1) if the documents have any key-value pairs or array elements in common, and false (0) if they don’t.

The JSON_OVERLAPS() function was added in MySQL 8.0.17.

Read more

About the JSON_MERGE() Function in MySQL

In MySQL, JSON_MERGE() is a deprecated function that merges two or more JSON documents and returns the result.

It was deprecated in MySQL 8.0.3 and is subject to removal in a future release.

Fortunately, the JSON_MERGE_PRESERVE() function was added in MySQL 8.0.3 as a synonym for JSON_MERGE(), and it therefore does the same thing that JSON_MERGE() does/did.

Therefore, instead of using JSON_MERGE(), use JSON_MERGE_PRESERVE() instead.

Alternatively, you can use JSON_MERGE_PATCH(), which performs an RFC 7396 compliant merge of two or more JSON documents, without preserving members having duplicate keys.

Read more

How CAST() Works in MySQL

In MySQL, CAST() is a built in function that converts a value to another data type. It takes a value of one type and returns a value of the specified type.

You provide the value as an argument when you call the function, as well as the type that you’d like it converted to.

CAST() works similar to CONVERT(), except that the syntax used is slightly different.

Read more

Redis ZLEXCOUNT Command Explained

In Redis, the ZLEXCOUNT command returns the number of elements in a sorted set with a value between two given values. It can be used when we force lexicographical ordering by applying the same score to all members of a sorted set.

Read more

How LAST_INSERT_ID() Works in MySQL

In MySQL, the LAST_INSERT_ID() function returns the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT statement.

It can also be called with an argument, in which case, it returns the value of the expression and the next call to LAST_INSERT_ID() will return the same value.

Read more