Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Oracle FROM


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

Syntax:

  1. FROM table_name…
  2. 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:

  1. CREATE TABLE  “CUSTOMERS”
  2.    (    “NAME” VARCHAR2(4000),
  3.     “AGE” NUMBER,
  4.     “SALARY” NUMBER,
  5.     “STATE” VARCHAR2(4000)
  6.    )
  7. /

customertable

Execute this query:

  1. SELECT *
  2. FROM customers
  3. WHERE salary >= 20000
  4. ORDER BY salary ASC;

Output:

fromoutput1

Oracle FROM Clause Example: (with two tables)

Inner Join example:

Let’s take two tables “suppliers” and “order1”.

Suppliers:

inner-join2

inner-join-supplier

Order1:

inner-join3

 

Execute the following query:

  1. SELECT suppliers.supplier_id, suppliers.supplier_name, order1.order_number
  2. FROM suppliers
  3. INNER JOIN order1
  4. ON suppliers.supplier_id = order1.supplier_id;

Output:

Comments

comments