P
P
Peter2022-04-13 20:09:30
MySQL
Peter, 2022-04-13 20:09:30

Create JSON index for mysql 8?

there is an employees field of type JSON in the following format: [
{
"id": 1,
"name": "Garina Irina Petrovna"
},

{
"id": 2,
"name": "Ivanov Ivan Ivanovich"
}

]

How to add an index to table, by ID?

Tried something like:
CREATE INDEX id_employees_index ON visits employees->>'$.id' AS INT

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2022-04-13
@rPman

look

CREATE INDEX id_employees_index ( (JSON_VALUE(visits, '$.id' RETURNING UNSIGNED)) )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question