mysql 字符串截取

  自定义变量jsonString,substring_index(@jsonString, '"},"', 1),截取正数第1个"},"之前的全部字符;substring_index(substring_index(@jsonString, '"},"', 1) , ':"', -1),截取倒数数第1个"},"之后的全部字符;【可以直接执行,@jsonString是要截取的字段】

set @jsonString= '[{"score":{"min":"0","max":"60"},"code":"差"},{"score":{"min":"60","max":"80"},"code":"中"},{"score":{"min":"80","max":"90"},"code":"良"},{"score":{"min":"90","max":"100"},"code":"优"}]';

SELECT

  @jsonString,

  substring_index(@jsonString, '"},"', 1),

  substring_index(substring_index(@jsonString, '"},"', 1) , ':"', -1)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpyjjg.html