MySQL 5.7.9 has a new feature, that simplifies queries that deal with JSON data and makes more human-readable: inlined JSON path expressions. Now you can do following:
mysql> CREATE TABLE employees (data JSON);
Query OK, 0 rows affected (0,01 sec)
mysql> INSERT INTO employees VALUES ('{"id": 1, "name": "Jane"}');
Query OK, 1 row affected (0,00 sec)
mysql> INSERT INTO employees VALUES ('{"id": 2, "name": "Joe"}');
Query OK, 1 row affected (0,00 sec)
mysql> SELECT * FROM employees WHERE data->'$.id'= 2;
+--------------------------+
| data |
+--------------------------+
| {"id": 2, "name": "Joe"} |
+--------------------------+
1 row in set (0,01 sec)
Let’s take a closer look at the expression in the
WHERE clause.…