FROM Clause in Oracle

From clause is one of the important clauses of the Oracle SQL query.

It helps to retrieve data from a single table or view, multiple tables or views, and in-line queries.

One table is mandatory to be mentioned in the from clause of the query.

If there are multiple tables, they are joined either using standard Oracle standards or ANSI standards.

FROM CLAUSE

Syntax

SELECT *
  FROM [schema_name.]table_name_1
       [, table_name_2...table_name_n]
       [,in-line query]
 WHERE condition_1
   AND condition_2
   .....
   .....
   AND condition_n;
Parameters Explanation

schema_name (optional)

  • Schema name in which the table is present

table_name_1, table_name_2…table_name_n

  • Table names to retrieve data from

condition_1, condition_2…condition_n

  • Conditions to filter the retrieved data

in-line query

  • In-line query to retrieve data from

Example

  • Data retrieved from a single table
SELECT * FROM employees;

This query fetches all records from the employees table in this example.

  • Data retrieved from multiple tables using joins
SELECT e.emp_name, d.dept_name
  FROM employees e, departments d
 WHERE e.dept_id = d.dept_id;

Joining column dept_id from employees and departments table fetch employee name and department name in this example

  • Data retrieved by joining tables and in-line queries
SELECT e.*
FROM employees e, (SELECT d.dept_id, d.dept_name 
                     FROM departments d) dept
WHERE e.dept_id = dept.dept_id;

Joining an in-line query with the employees table fetches all columns of the employees table in this example.

I hope you like the page and find it useful. We highly appreciate comments and feedback.

You can also Subscribe here to stay updated on latest posts of OracleMine.com.

Hi I am Paras.

Thanks for stopping by at OracleMine.com. Speaking about my brief introduction, I work for a multinational organisation in Oracle related technologies. Being an avid blogger, I would like to inform you about my productivity and motivational blog XpressPlanet.com. Speaking of OracleMine.com, I will try my best to share knowledge on technologies in as simple and understandable manner as possible. You can also contribute your knowledge on OracleMine by writing to us at hioraclemine@gmail.com. Again I appreciate your visit. Hope to see you again and again!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.