MySQL Json int type array query

the simple table structure is as follows

< table > < thead > < tr > < th > ID < / th > < th > TypeID < / th > < / tr > < / thead > < tbody > < tr > < td > 1 < / td > < td > [1,2] < / td > < / tr > < tr > < td > 2 < / td > < td > [2,3] < / td > < / tr > < / tbody > < / table >

TypeID is of type Json

how do I find all the data that TypeID contains 2 ?

  • the official tutorial does not demonstrate how to filter in top-level elements, only filtering child elements
  • SELECT * FROM module WHERE JSON_EXTRACT (module.TypeID,"$[*]") = 2; has no effect
Oct.22,2021

SELECT * FROM module WHERE JSON_CONTAINS(module.TypeID, '[2]');
  • How does mysql extract JSON data?

    when dealing with the data of a mysql table, it is encountered that the content stored in a field is as follows: a:2:{ i:0; a:2:{i:0;i:0;i:1;s:9:"";} i:1; a:2:{i:0;i:0;i:1;s:9:"";} } I want to use sql to put forwa...

    Mar.08,2022
  • How does mysql extract JSON data?

    when dealing with the data of a mysql table, it is encountered that the content stored in a field is as follows: a:2:{ i:0; a:2:{i:0;i:0;i:1;s:9:"";} i:1; a:2:{i:0;i:0;i:1;s:9:"";} } I want to use sql to put forwa...

    Mar.08,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b813-4d939.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b813-4d939.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?