SELECT * FROM taxonomy_term_data AS ttd LEFT JOIN taxonomy_term_hierarchy AS tth ON ttd.tid = tth.tid WHERE (SELECT vid FROM taxonomy_vocabulary WHERE machine_name = 'test_words') = ttd.vid