the data type of JSON ?
sql
CREATE TABLE `A`.`B`(`C` ID, `D` JSON NOT NULL):
sql
INSERT INTO `A`.`B`(`D`) VALUES (JSON_OBJECT('something', JSON_ARRAY('whatever_one', 'whatever_two', 'whatever_three')));
Expecting:
json
{"something", [{"whatever_one", "whatever_two", "whatever_two"}]}
Any Idea by using php?
I tried
sql
SELECT * FROM `A`.`B`;
I wasn't print out the JSON colum as JSON.
It's OK, I found out a solution. mysql SELECT JSON_EXTRACT( `{NAME_OF_COLUMN}`, '$.{NAME_OF_JSON_OBJECT}' ) FROM `{NAME_OF_DATABASE}`.`{NAME_OF_TABLE}`
you can do select NAME_OF_JSON_COLUMN->'$.JSON_KEY' from table , instead of JSON_EXTRACT
Обсуждают сегодня