Retrieve JSON

You can retrieve the fields of the JSON column using the -> and ->> operators:

mysql> SELECT emp_no, details->'$.address.pin' pin FROM emp_details;+--------+----------+| emp_no | pin      |+--------+----------+| 1      | "560103" |+--------+----------+1 row in set (0.00 sec)

To retrieve data without quotes, use the ->> operator:

mysql> SELECT emp_no, details->>'$.address.pin' pin FROM emp_details;+--------+--------+| emp_no | pin    |+--------+--------+| 1      | 560103 |+--------+--------+1 row in set (0.00 sec)

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.