MySQL错误代码:1305.在MySQL客户端版本中不存在FUNCTION JSON_EXTRACT:5.5.52

Sha*_*hah 4 php mysql json

目标: - json_extract不存在错误.

我确实有这样的消息体.

  < message type = "chat"
  to = "socialapp_233@22.52.258.256"
  from = "socialapp_6@22.52.258.256/9fs4kgn090" > < body > {
    "opponent_xmpp_id": "socialapp_233@22.52.258.256",
    "latest_message_id": "6233"
  } < /body><active>http:/ / jabber.org / protocol / chatstates < /active></message >
Run Code Online (Sandbox Code Playgroud)

我正在尝试提取opponent_xmpp_idlatest_message_id.

因为我写了一个如下的查询.

SELECT  LEFT(ExtractValue( stanza, "//@from" ),LOCATE("@",ExtractValue( stanza, "//@from" )) - 1),
        LEFT(ExtractValue( stanza, "//@to" ),LOCATE("@",ExtractValue( stanza, "//@to" )) - 1),
        ExtractValue(stanza, "//body"),
        ExtractValue(stanza, "//@chattype"),
        TRIM(BOTH '"' FROM json_extract(ExtractValue(stanza, "//body"), '$.opponent_xmpp_id')) AS opponent_xmpp_id,
        json_extract(ExtractValue(stanza,"//body"),'$.latest_message_id') AS latest_message_id        
FROM
ofOffline
Run Code Online (Sandbox Code Playgroud)

导致错误

1305 - FUNCTION databaseName.json_extract不存在

据我所知,仅在> MYsql 5.7版本中搜索其支持.

那么在MySQL客户端版本中是否有任何函数可以像json_extract一样进行simmilar工作:5.5.52?

e4c*_*4c5 5

mysql客户端的版本不相关.mysql服务器中存在(或在您的情况下不存在)功能.因此,唯一相关的是mysql服务器版本.此功能仅在mysql server 5.7及更高版本中可用.升级客户端无法解决问题,您需要升级服务器.

有工作吗?是.PHP的json_decode

这可以工作,因为您的查询没有WHERE子句.你正在看整个桌子.因此,您可以轻松获取所有数据和json_decode,然后在PHP代码中进行处理.如果您有大量数据,这将非常慢.