Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dictionary database
8. Dictionary table – exercise 3
Summary

Instruction

Okay, here comes the last exercise with this table!

Exercise

For each entry in the dictionary show the word, its direct hypernym and its hypernym's hypernym. Name the columns entry, hypernym and grandhypernym, respectively. Show all such entries, even those that don't have direct hypernyms or grandhypernyms.

Stuck? Here's a hint!

Use LEFT JOIN twice.

Type:

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