mysql - json path in mariadb

currently using mysql 5.7 I can execute the following query accessing a json field in the database:

select myData->'$[0].dataflow' from flowtable limit 1;

If I try the same query on MariaDB it does not work, is there any solution to this problem? I thought MariaDB was fully compatible with mysql and what would it be the correspondent MariaDB syntax?


1 Answer

  1. Charles- Reply


    In MySQL, JSON_EXTRACT() was added in 5.7.8:

    JSON_EXTRACT(json_doc, path[, path] ...)


    MySQL 5.7.9 and later supports the -> operator as shorthand for this (JSON_EXTRACT()) function ...


    In MariaDB (starting with 10.2.3) use JSON_EXTRACT() function, since -> operator is not currently implemented.


    SELECT `myData` -> '$[0].dataflow'
    FROM `flowtable`
    LIMIT 1;

    MySQL and MariaDB:

    SELECT JSON_EXTRACT(`myData`, '$[0].dataflow')
    FROM `flowtable`
    LIMIT 1;

    See, MySQL db-fiddle and MariaDB dbfiddle.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>