Oracle FROM Clause

FROM clause is a mandatory clause in SELECT expression. It specifies the tables from which data is to be retrieved.

Syntax:

snippet
FROM table_name...
Expressions...

Oracle FROM Clause Example: (with one table)

Let's take an example to explain how to use FROM clause to retrieve data from one table. Consider a table "customers".

Customer table:

snippet
CREATE TABLE  "CUSTOMERS" 
   (	"NAME" VARCHAR2(4000), 
	"AGE" NUMBER, 
	"SALARY" NUMBER, 
	"STATE" VARCHAR2(4000)
   )
/
Customer Table

Execute this query:

snippet
SELECT *
FROM customers
WHERE salary >= 20000
ORDER BY salary ASC;

Output:

Oracle from example

Oracle FROM Clause Example: (with two tables)

Inner Join example:

Let's take two tables "suppliers" and "order1".

Suppliers:

Oracle Inner Join Oracle Inner Join supplier

Order1:

Oracle Inner Join Oracle Inner Join order

Execute the following query:

snippet
SELECT suppliers.supplier_id, suppliers.supplier_name, order1.order_number
FROM suppliers
INNER JOIN order1
ON suppliers.supplier_id = order1.supplier_id;

Output:

Oracle from example 5
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +