Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Access JSON column

How can I access values in the status and date columns stored as JSON?
Please, have a look at an example row below.

{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Demo:

set @j = '{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}';

select json_extract(@j, '$."1".status') as status;
+--------+
| status |
+--------+
| true   |
+--------+

In this case, it may be unexpected that you need to put double-quotes around "1" to use it in a JSON path.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading