0
Follow
2
View

Filtering multiple items in json array with sqlite json_each

cyok5656 注册会员
2023-01-25 11:57

You can do it with aggregation:

SELECT f.* 
FROM Feeds f, json_each(groups) t 
WHERE t.value IN ('fav1', 'fav2')
GROUP BY f.id
HAVING COUNT(DISTINCT t.value) = 2;

You can change COUNT(DISTINCT t.value) to just COUNT(*) if there are no duplicates inside the json array.

See the demo.

About the Author

Question Info

Publish Time
2023-01-25 11:57
Update Time
2023-01-25 11:57