1.函数 JSON_EXTRACT
表数据格式:
查询结果:
sql 语句:
-- ---------------------------- -- Table structure for jsonarray_test -- ---------------------------- DROP TABLE IF EXISTS `jsonarray_test`; CREATE TABLE `jsonarray_test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', UNIQUE KEY `title` (`title`), KEY `id` (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of jsonarray_test -- ---------------------------- INSERT INTO `jsonarray_test` VALUES ('1', '[{"id":1,"name":"张三"},{"id":1,"name":"李四"},{"id":3,"name":"王五"}]'); SELECT id, REPLACE ( JSON_EXTRACT (title, '$[*].name'), '"', '' ) AS 'name' FROM jsonarray_test
整体截图: