1

I am using the following query to search for a json value named "JavaScript"

When I run the query I get 0 results

This is my insert command I am using

INSERT INTO admin_acc_mngmt_notes (tags) VALUES('["JavaScript"]')

This is the search query I am using:

SELECT * FROM admin_acc_mngmt_notes WHERE JSON_CONTAINS(tags,'["JavaScript"]');

Any help would be really appreciated!

dreftymac
  • 31,404
  • 26
  • 119
  • 182
json6
  • 85
  • 5
  • I tested with MySQL 8.0.1 and it works perfectly. What version are you using? When you get 0 results, do you get any error? – Bill Karwin Sep 03 '17 at 01:53
  • Hi Bill. I found out the answer SELECT * FROM `admin_acc_mngmt_notes` WHERE JSON_SEARCH(tags, 'all', 'JavaScript') IS NOT NULL – json6 Sep 03 '17 at 04:10
  • Very well. You should post that as a solution, and accept it, so this question doesn't get treated as an "unanswered" question forever. – Bill Karwin Sep 03 '17 at 04:28
  • Thanks i did it! – json6 Sep 05 '17 at 18:57

1 Answers1

3

I found out the answer myself:

SELECT * FROM admin_acc_mngmt_notes WHERE JSON_SEARCH(tags, 'all', 'JavaScript') IS NOT NULL 
dylanvanw
  • 3,029
  • 1
  • 8
  • 18
json6
  • 85
  • 5