How to Return Elements from a JSON Array in MariaDB

MariaDB includes two selectors that enable us to select elements from JSON arrays:

  • [N] selects element number N in the array (for example, [0] to select the first element).
  • [*] selects all elements in the array.

These can be used in a number of JSON functions that are included in MariaDB. The following examples use them with the JSON_EXTRACT() function in order to return selected array elements.

Continue reading

How to Return the Day Number with a Suffix in MariaDB

MariaDB includes a large collection of date and time functions that return a given date in a certain format.

One thing you can do is return the day number with the relevant “st/nd/rd/th” suffix. For example, instead of returning it as say, 10 July 2025, it’s returned as 10th July 2025.

Below is an example of adding the relevant suffix to a day number in MariaDB.

Continue reading