Json extract of ['a','b','c']



  • My json is of the format ["a","b","c"]. I want to write a sql query such that

    select *
    from mytable
    where a_column in json_extract["a","b","c"]
    

    This logic does not work, because json_extract needs a path.

    Is there any work around for this in mysql 8.0



  • SELECT *
    FROM mytable
    WHERE JSON_CONTAINS('["a","b","c"]', JSON_QUOTE(a_column));
    

    I assume that the column a_column is a string-type column which contains a value like 'a'.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2