From (SQL)

The SQL From clause is the source of a rowset to be operated upon in a Data Manipulation Language (DML) statement. From clauses are very common, and will provide the rowset to be exposed through a Select statement, the source of values in an Update statement, and the target rows to be deleted in a Delete statement. [1]

`FROM` is an SQL reserved word in the SQL standard. [2]

The `FROM` clause is used in conjunction with SQL statements, and takes the following general form:

SQL-DML-Statement
FROM table_name
WHERE predicate

The From clause can generally be anything that returns a rowset, a table, view, function, or system-provided information like the Information Schema, which is typically running proprietary commands and returning the information in a table form.[3]

## Examples

[edit]

The following query returns only those rows from table mytable where the value in column mycol is greater than 100.

SELECT *
FROM   mytable
WHERE  mycol > 100

## Requirement

[edit]

The From clause is technically required in relational algebra and in most scenarios to be useful. However many relational DBMS implementations may not require it for selecting a single value, or single row - known as DUAL table in Oracle database.[4]

SELECT 3.14 AS Pi

Other systems will require a From statement with a keyword, even to select system data.[5]

select to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Time"
from dual;

## References

[edit]

1. ^ "From clause in Transact SQL".
2. ^ "Reserved Words in SQL".
3. ^ "System Information Schema Views (Transact-SQL)".
4. ^ "Selecting from the DUAL Table".
5. ^ "Oracle Dates and Times".

* v
* t
* e

SQL

Versions|

* SEQUEL
* SQL-86
* SQL-89
* SQL-92
* SQL:1999
* SQL:2003
* SQL:2006
* SQL:2008
* SQL:2011
* SQL:2016
* SQL:2023

Keywords|

* As
* Case
* Create
* Delete
* From
* Group by
* Having
* Insert
* Join
* Merge
* Null
* Order by
* Over
* Prepare
* Select
* Truncate
* Union
* Update
* With

Related|

* Edgar Codd
* Relational database

ISO/IEC SQL parts|

* Framework
* Foundation
* Call-Level Interface
* Persistent Stored Modules
* Management of External Data
* Object Language Bindings
* Information and Definition Schemas
* SQL Routines and Types for the Java Programming Language
* XML-Related Specifications

*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template