I am testing this example.
JSON_TABLE – The Best of Both Worlds
I understand that t1 is the table and people the array but where do I put the name of the column?
INSERT INTO t1 VALUES (
'{ "people": [
{ "name":"John Smith", "address":"780 Mission St, San Francisco, CA 94103"},
{ "name":"Sally Brown", "address":"75 37th Ave S, St Cloud, MN 94103"},
{ "name":"John Johnson", "address":"1262 Roosevelt Trail, Raymond, ME 04071"}
] }'
);
They call the column json_col but they only use it in a select query like this.
SELECT people.*
FROM t1,
JSON_TABLE(json_col, '$.people[*]' COLUMNS (
name VARCHAR(40) PATH '$.name',
address VARCHAR(100) PATH '$.address')
) people;
json_colis the name of the column (CREATE TABLE t1(json_col JSON);). For insertion, you can also useINSERT INTO t1(json_col) VALUES (...)