Tables Are Just One of the Things You Can Put in a FROM Clause

From WikiContent

Revision as of 15:58, 22 January 2010 by Albeau (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

If you were to read a definition of the FROM clause in many of the introductory SQL books, you might see something like the following:

The FROM clause identifies one or more tables from which data is to be retrieved

While this is certainly true and covers a large percentage of use cases, it is far from being a comprehensive definition. Depending on which database server you are using, the elements referenced in your FROM clause may be of any of the following types:

Tables Views Subqueries Files XML Documents Functions

Did you know that you can write a query that will read data from a file on the server? Or interact with the results of another query as if it were a table? Or, my favorite, process the results of a function call which returns a result set? If not, then you owe it to yourself to find out all the ways in which your database server can interact with various sources, whether they be managed locally or remotely.

So, a far better definition would be:

The FROM clause identifies one or more data sources from which data is to be retrieved

Personal tools