How To Write a Query with an Inner Join in Oracle?
Submitted by: AdministratorIf you want to query from two tables with an inner join, you can use the INNER JOIN ... ON clause in the FROM clause. The following query returns output with an inner join from two tables: employees and departments. The join condition is that the department ID in the employees table equals to the department ID in the departments table:
SQL> SELECT employees.first_name, employees.last_name,
2 departments.department_name
3 FROM employees INNER JOIN departments
4 ON employees.department_id=departments.department_id;
<pre>FIRST_NAME LAST_NAME DEPARTMENT_NAME
-------------------- -------------------- ---------------
Steven King Executive
Neena Kochhar Executive
Lex De Haan Executive
Alexander Hunold IT
Bruce Ernst IT
David Austin IT
Valli Pataballa IT
......</pre>
Note that when multiple tables are used in a query, column names need to be prefixed with table names in case the same column name is used in both tables
Submitted by: Administrator
SQL> SELECT employees.first_name, employees.last_name,
2 departments.department_name
3 FROM employees INNER JOIN departments
4 ON employees.department_id=departments.department_id;
<pre>FIRST_NAME LAST_NAME DEPARTMENT_NAME
-------------------- -------------------- ---------------
Steven King Executive
Neena Kochhar Executive
Lex De Haan Executive
Alexander Hunold IT
Bruce Ernst IT
David Austin IT
Valli Pataballa IT
......</pre>
Note that when multiple tables are used in a query, column names need to be prefixed with table names in case the same column name is used in both tables
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Write Date and Time Interval Literals in Oracle? |
☺ | What Is Input Buffer in SQL*Plus? |
☺ | How Oracle Handles Dead Locks? |
☺ | How To Call a Stored Function in Oracle? |
☺ | What Is the Relation of a User Account and a Schema? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Forms Reports Interview Questions. |