Is any way to set unique key for json array, and can get key of items of array ?
Posted by: wylton wa
Date: September 07, 2018 02:28PM

I have a table like this:
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| Id | int(11) | NO | PRI | NULL | auto_increment |
| codigo | varchar(16) | NO | UNI | NULL | |
| names | json | NO | | NULL | |
+--------+-------------+------+-----+---------+----------------+

mysql> select * from test02;
+----+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Id | codigo | names |
+----+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | 8413951000500 | [{"name": "QUITA ATASCO REF:43ATASC", "locale": "ES"}, {"name": "通管道液体", "locale": "ZH"}] |
| 2 | 8608699005201 | [{"name": "DESATASCADOR 1.4M K100482", "locale": "ES"}, {"name": "摇把疏通器", "locale": "ZH"}, {"name": "changes", "locale": "EN"}] |
| 3 | 8414926294702 | [{"name": "CESTA MIMBRE MULTIUSOS", "locale": "ES"}, {"name": "竹篮子", "locale": "ZH"}] |
+----+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0,01 sec)

I want unique key in "locale" for update o insert.
and I want can get "name" key/value when search like < where names->'$'->'locale' = "ES" >..

Options: ReplyQuote


Subject
Views
Written By
Posted
Is any way to set unique key for json array, and can get key of items of array ?
280
September 07, 2018 02:28PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.