SQL queries with foreign keys or database is hierarchical

In this article I intend to discuss a way to query database(relational : unique data is stored in a row of table) using SQL when 1) Hierarchical Data is stored in database.2) There are 2 or more tables and 1 table contains a column which ho