1

I'm trying to use the JSON_EXTRACT function in MySQL, but when I run the query:

SELECT JSON_EXTRACT('{"username":"Olivia"}', '$.username'); 

I receive the error: Error Code: 1305. FUNCTION JSON_EXTRACT does not exist.

I was under the impression that JSON_EXTRACT was a MySQL built in function, but was I mistaken? If anyone knows how to correct this, I'd appreciate it. Thanks!

6
  • 2
    Yes this function is available since v-5.7 of mysql, you may have a lower version of mysql. Check your mysql version. Commented Oct 20, 2016 at 9:41
  • Thanks, I think have "mysql Ver 14.14 Distrib 5.7.15" and in my settings it shows the following: MySQL Workbench Community (GPL) for Windows version 6.3.7 CE build 1199 (64 bit) Commented Oct 20, 2016 at 14:03
  • Hi @AbhikChakraborty I do have same issue as olivia has is there any different function forl MySQL client version: 5.5.52 ? Commented Nov 4, 2016 at 5:04
  • @ShashankShah no for mysql 5.5.52 this function is not available and only available since 5.7. I am not sure why Olivia was facing this issue since this function should be available for V-5.7 Commented Nov 4, 2016 at 16:25
  • @ShashankShah do you any solution for this? i also have lower version Commented Nov 20, 2017 at 10:15

1 Answer 1

0

It's seems like you are trying to get value from the field that contain object value.

The function JSON_EXTRACT supported from MySQL version 5.7.8

If you want get value from the file that contain object value on MySQL server version <5.7.8, you can use alternative function.

REPLACE( SUBSTRING_INDEX(SUBSTRING_INDEX('{"username":"Olivia"}', '"username":"', -1), '",', 1), '\', '' ) AS username

Hope this will be solution for you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.