MySQL错误代码:1305。函数JSON_EXTRACT在MySQL客户端版本5.5.52中不存在

时间:2021-08-14 15:59:28

Goal :- json_extract does not exist error.

目的:- json_extract不存在错误。

I do have message body like this.

我确实有这样的消息体。

  < 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 >

I am trying to extract opponent_xmpp_id and latest_message_id.

我正在尝试提取反对党_xmpp_id和latest_message_id。

for that i have written a query like below.

为此,我编写了如下所示的查询。

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

causes error

导致错误

1305 - FUNCTION databaseName.json_extract does not exist

As per i searched its supporting in > MYsql 5.7 version only.

我在>的MYsql 5.7版本中搜索了它的支持。

So is there any function which do the simmilar job as json_extract in MySQL client version: 5.5.52 ?

在MySQL客户端版本中,是否有任何函数可以作为json_extract的simmilar工作:5.5.52 ?

1 个解决方案

#1


4  

The version of mysql client is not relevant. The functionality exists (or in your case does not exist) in the mysql server. Thus the only thing that's relevant is the mysql server version. And this functionality is available only in mysql server 5.7 onwards. Upgrading your client will not solve the problem, you need to upgrade your server.

mysql客户端版本不相关。该功能在mysql服务器中存在(或者在您的例子中不存在)。因此,唯一相关的是mysql服务器版本。这个功能只能在mysql server 5.7或更高版本中使用。升级您的客户端不会解决问题,您需要升级您的服务器。

Is there a work around? yes. PHP's json_decode

附近有工作吗?是的。PHP的json_decode

This can work because your query does not have a WHERE clause. You are looking at the entire table. So you can just as easily fetch all that data and json_decode and then do the processing in your PHP code. This is going to be very slow if you have a lot of data though.

这可以工作,因为查询没有WHERE子句。你在看整张桌子。你可以很容易地获取所有的数据和json_decode然后在PHP代码中进行处理。如果你有很多数据,这将是非常缓慢的。

#1


4  

The version of mysql client is not relevant. The functionality exists (or in your case does not exist) in the mysql server. Thus the only thing that's relevant is the mysql server version. And this functionality is available only in mysql server 5.7 onwards. Upgrading your client will not solve the problem, you need to upgrade your server.

mysql客户端版本不相关。该功能在mysql服务器中存在(或者在您的例子中不存在)。因此,唯一相关的是mysql服务器版本。这个功能只能在mysql server 5.7或更高版本中使用。升级您的客户端不会解决问题,您需要升级您的服务器。

Is there a work around? yes. PHP's json_decode

附近有工作吗?是的。PHP的json_decode

This can work because your query does not have a WHERE clause. You are looking at the entire table. So you can just as easily fetch all that data and json_decode and then do the processing in your PHP code. This is going to be very slow if you have a lot of data though.

这可以工作,因为查询没有WHERE子句。你在看整张桌子。你可以很容易地获取所有的数据和json_decode然后在PHP代码中进行处理。如果你有很多数据,这将是非常缓慢的。