JSON_EXTRACT() – Return Data from a JSON Document in MySQL

In MySQL, the JSON_EXTRACT() function returns data from a JSON document. The actual data returned is determined by the path you provide as an argument.

You provide the JSON document as the first argument, followed by the path of the data to return. You can also provide multiple paths to return data from multiple places in the document.

Read more

JSON_CONTAINS() Examples in MySQL

In MySQL, the JSON_CONTAINS() function tests whether or not a specified value is found in the given JSON document or, optionally, at the specified path within the document.

If the value is found, JSON_CONTAINS() returns 1, otherwise it returns 0.

Read more

JSON_REPLACE() – Replace Values in a JSON Document in MySQL

In MySQL, the JSON_REPLACE() function replaces values in a JSON document and returns the result.

You provide the JSON document as the first argument, followed by the path to replace data at, followed with the value to replace the existing value with.

You can replace data at multiple places in the document if required. To do this, simply provide multiple path/value pairs as required.

Read more

JSON_MERGE_PATCH() vs JSON_MERGE_PRESERVE() in MySQL: What’s the Difference?

MySQL includes a number of functions for working with JSON documents. Among these are the JSON_MERGE_PATCH() and JSON_MERGE_PRESERVE() functions.

Both of these functions merge two or more JSON documents and return the result. However, there are certain cases where these functions will return a different result. You need to be aware of this before including them in any of your queries.

Read more