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

From WikiContent

(Difference between revisions)
Jump to: navigation, search
(New page: 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 w...)
Line 1: Line 1:
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:
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
+
''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:
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
+
* Tables
-
Views
+
* Views
-
Subqueries
+
* Subqueries
-
Files
+
* Files
-
XML Documents
+
* XML Documents
-
Functions
+
* 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.
+
Did you know that you can write a query that will open and read data from a file on the server? Or interact with the results of another query as if it were a table? Or, my personal 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 are managed locally or remotely.
-
So, a far better definition would be:
+
Therefore, a far better definition of the FROM clause would be:
-
The FROM clause identifies one or more data sources from which data is to be retrieved
+
''The FROM clause identifies one or more data sources from which data is to be retrieved''
 +
 
 +
Using this definition, you can do far more intesting things than what is shown in most introductory SQL books.

Revision as of 16:18, 22 January 2010

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 open and read data from a file on the server? Or interact with the results of another query as if it were a table? Or, my personal 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 are managed locally or remotely.

Therefore, a far better definition of the FROM clause would be:

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

Using this definition, you can do far more intesting things than what is shown in most introductory SQL books.

Personal tools