Untitled
SELECT t.name, COUNT(vc.entity_id), if (p.parent_target_id =0, p.entity_id, p.parent_target_id) as tag_id FROM `node__field_video_category` vc INNER JOIN taxonomy_term__parent p on p.entity_id = vc.field_video_category_target_id LEFT JOIN taxonomy_term_field_data t on t.tid = p.parent_target_id OR vc.field_video_category_target_id = t.tid GROUP BY tag_id;
Leave a Comment