The FROM clause is required in every SELECT statement in which data is being retrieved from tables or views. Use the FROM clause to:
The FROM clause is a comma-separated list of table names, view names, and JOIN clauses.
Transact-SQL has extensions that support the specification of objects other than tables or views in the FROM clause. These other objects return a result set, or rowset in OLE DB terms, that form a virtual table. The SELECT statement then operates as if the result set were a table.
The FROM clause can specify:
SELECT *
FROM Shippers
SELECT Cst.CustomerID, Cst.CompanyName, Cst.ContactName,
Ord.ShippedDate, Ord.Freight
FROM Northwind.dbo.Orders AS Ord
JOIN
Northwind.dbo.Customers AS Cst
ON (Cst.CustomerID = Ord.CustomerID)
SELECT ST.stor_id, ST.stor_name
FROM stores AS ST,
(SELECT stor_id, COUNT(DISTINCT title_id) AS title_count
FROM sales
GROUP BY stor_id
) AS SA
WHERE ST.stor_id = SA.stor_id
AND SA.title_count = (SELECT COUNT(*) FROM titles)
The basis of Microsoft® SQL Server™ distributed queries are linked servers, OPENROWSET, and OPENQUERY. They provide the ability to query or modify data in any OLE DB data source as a part of Transact-SQL statements.
The SELECT statements that do not require a FROM clause are those that are not selecting data from any tables in the database. These SELECT statements only select data from local variables or Transact-SQL functions that do not operate on a column, for example:
SELECT @MyIntVariable
SELECT @@VERSION
SELECT DB_ID('Northwind')
Distributed Queries | OPENROWSET |
FROM | OPENQUERY |
Query Tuning | Using Joins |