从列中的所有json数组获取唯一/不同的值

时间:2020-07-12 02:52:31

标签: mysql mysql-8.0

我正在将genres的电影存储在MySQL 8.0数据库中,其列为JSON类型。我正在尝试从列中的所有数组获取所有唯一值。我已经尝试了很多但没有成功。任何帮助将非常感谢。

My Current Query which is returning all the values but there are duplicates

SELECT JSON_EXTRACT(JSON_ARRAYAGG(`genres`), '$[*][*]') FROM `movie`;

["Biography", "Comedy", "Action", "Drama", "Action", "Comedy", "Comedy", "Drama", "Mystery", "Action", "Adventure", "Animation", "Comedy", "Family", "Fantasy", "Sci-Fi", "Action", "Crime", "History", "Thriller", "Comedy", "Drama", "Romance", "Action", "C...

Data View

+--------------------------------------------+
| genres                                     |
+--------------------------------------------+
| ["Biography", "Comedy"]                    |
| ["Action", "Drama"]                        |
| ["Action", "Comedy"]                       |
| ["Comedy", "Drama", "Mystery"]             |
| ["Action", "Adventure", "Animation"]       |
| ["Action", "Crime", "History", "Thriller"] |
| ["Comedy", "Drama", "Romance"]             |
| ...                                        |
| ...                                        |
| ...                                        |
+--------------------------------------------+

0 个答案:

没有答案