Skip to content
Advertisement

How to select a nested item of json datatype?

I have a MySQL table named computers with a column named details that is json data type formatted. I’ve inserted a value like this in that column:

I can simple get Chrome value by the following query:

Now I want to know, how can I get 1680 value (which is the value of x) ?

Advertisement

Answer

You can alter your query to:

Or use JSON_EXTRACT:

Result:

Fiddle here.

Note: As mentioned above, its not good practice to store information you plan on retrieving in a JSON column, create a dedicated value to store this information.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement