SELECT t.value, count(*) as users_count
FROM users u
JOIN (
SELECT d1.text as value, d1.user_id FROM data1 d1
UNION
SELECT d2.name as value, d2.user_id FROM data2 d2
) t on t.user_id = u.id
GROUP BY t.value
ORDER BY users_count DESC
select *
from tbl
where JSON_CONTAINS(filters, '{"1":["0"]}') = 1
OR JSON_CONTAINS(filters, '{"1":["3"]}') = 1