亚洲国产第一_开心网五月色综合亚洲_日本一级特黄特色大片免费观看_久久久久久久久久免观看

Hello! 歡迎來到小浪云!


如何在 MySQL 5.7 中統計 JSON 數組中特定值的計數?


avatar
小浪云 2024-11-10 178

如何在 MySQL 5.7 中統計 JSON 數組中特定值的計數?

如何在 mysql 5.7 中統計 json 數組中特定值的計數

mysql 5.7 中無法使用 json_table 函數統計 json 數組中特定值的計數。一種替代方法是使用 json_search 函數,如下所示:

SELECT     count( JSON_SEARCH( tags, 'one', "3467562849402896" ) ),     count( JSON_SEARCH( tags, 'one', "3467562861985809" ) ),     count( JSON_SEARCH( tags, 'one', "3465044211793921" ) ) FROM     XXXXXXXXXX
登錄后復制

在這個查詢中:

  • xxxxxxxxxx 是包含 json 列 tags 的表名。
  • json_search 函數用于在 tags 數組中查找特定值(在本例中為 “3467562849402896”、”3467562861985809″ 和 “3465044211793921”)。
  • count 函數計算每個值的出現次數。

相關閱讀