The clue is in the “Relational” part of “Relational database”
A relation is a set of rows, and can therefore be:
- The rows in a table
- The rows projected from a view
- The rows projected from a query
- The rows projected from a common table expression
In theory, all of these are the same, and so selecting from a table is logically the same as selecting from a view, or from another query, and joining two tables is logically the same as joining two queries.
As to why it is done, here are three decent reasons:
- To avoid having to save a temporary result set into some structure and then read it out again.
- Because in some cases it is not possible to place a condition on a query through a WHERE or HAVING clause, and the predicate must be placed on the result set.
- Coding convenience.