Skip to Main Content

SELECT SQL expression without FROM clause

Gerald Venzl-OracleApr 27 2020 — edited May 7 2020

To select values from SQL expressions, a FROM clause is not strictly required as the expression is not selected from that table anyway.

For example:

SELECT sysdate;

SELECT 1+2;

SELECT my_fuction();

Oracle uses the FROM dual construct as a workaround for that scenario where dual is a dummy one-column, one-row table, translating the above to:

SELECT sysdate FROM dual;

SELECT 1_2 FROM dual;

SELECT my_function() FROM DUAL;

Although the SQL standard doesn't allow a SELECT statement without a FROM clause, pretty much every other database does support the construct of selecting and expression without a FROM clause. Especially for beginners, users coming from other databases and quick tests, not having to know of and type FROM dual all the time aids user-friendliness.

Comments
Post Details
Added on Apr 27 2020
1 comment
2,479 views