我正在使用一个表格,其中信息以JSON格式存储在表格中。 JSON值字段如下所示:
从k2_extra_fields中选择*,其中id = 2且已发布= 1;
id | value
2,[{"name":"Apples","value":1,"target":null,"alias":"","required":0,"showNull":1},{"name":"Pears","value":2,"target":null,"alias":"","required":0,"showNull":1},{"name":"Mangos","value":3,"target":null,"alias":"","required":0,"showNull":1},{"name":"Guava","value":4,"target":null,"alias":"Fruit","required":0,"showNull":1},{"name":"Pineapple","value":5,"target":null,"alias":"Fruit","required":0,"showNull":1}]
或逐行逐行查看值(减去ID):
[
{"name":"Apples","value":1,"target":null,"alias":"","required":0,"showNull":1},
{"name":"Pears","value":2,"target":null,"alias":"","required":0,"showNull":1},
{"name":"Mangos","value":3,"target":null,"alias":"","required":0,"showNull":1},
{"name":"Guava","value":4,"target":null,"alias":"Fruit","required":0,"showNull":1},
{"name":"Pineapple","value":5,"target":null,"alias":"Fruit","required":0,"showNull":1}
]
引导我的查询返回值3. 3 = Mangos。如何获取'3'值并将其与存储的名称/值匹配,以便我最终得到输出,Mangos?
答案 0 :(得分:0)
应该可以使用内置的mysql功能,但非常难,并且不聪明'想法。如果你真的需要在mysql中计算这个问题,你需要为你的mysql添加新的功能。查看UDF插件:http://dev.mysql.com/doc/refman/5.1/en/udf-compiling.html