从uknknown数组键中提取JSON

时间:2018-03-06 01:02:02

标签: mysql json

我有一个结构 - 列访问者

[{"firstname":"john","lastname":"penn"},{"firstname":"mickey","lastname":"smith"},{"firstname":"darth","lastname":"vader"}]

我想知道这个json里面列出的所有这些人中是否有一个约翰。

我的查询没有找到任何内容(找不到行)

SELECT conference_name FROM conference WHERE JSON_EXTRACT(visitors, "$[*].firstname") = 'john';

这是否可以实现只使用json_extract和NOT json_search,因为大表的速度很慢?

1 个答案:

答案 0 :(得分:0)

docs中提到的那样:

contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[icon(40)]-0-[title]-0-[status(30)]-0-|", options: [], metrics: nil, views: viewsDict))
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-[title]-[text]-|", options: [], metrics: nil, views: viewsDict))
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-40-[text]-30-|", options: [], metrics: nil, views: viewsDict))
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[icon(40)]", options: [], metrics: nil, views: viewsDict))
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[status(30)]", options: [], metrics: nil, views: viewsDict))

或者在您的情况下,您可以尝试

mysql> SELECT c, JSON_EXTRACT(c, "$.firstname"), g
 > FROM jemp
 > WHERE JSON_EXTRACT(c, "$.firstname") = 'john';

或?

SELECT conference_name FROM conference WHERE JSON_EXTRACT(visitors, "$.firstname") = 'john';