Introduction
Dictionary database
7. Dictionary table – exercise 2
Summary

Instruction

Good! You don't have to limit joining a table with itself to just a single join.

Exercise

Show each dictionary entry (name the column entry) together with the name of its direct hypernym (name the column hypernym) and the name of that hypernym's hypernym (name the column grandhypernym).

Only include words that have both a direct hypernym and a "grandhypernym".

Stuck? Here's a hint!

Type:

SELECT
  entry.word AS entry,
  hypernym.word AS hypernym,
  super_hypernym.word AS grandhypernym
FROM dictionary AS entry
JOIN dictionary AS hypernym
  ON entry.hypernym_id = hypernym.entry_id
JOIN dictionary AS super_hypernym
  ON hypernym.hypernym_id = super_hypernym.entry_id

Console

Code editor

Result

TableConsole