Follow Now on Insta

Oracle SQL Inner Joins - Industry Expert Explains

Hey there ! This is Industry Expert in Oracle SQL. I am going to explain about SQL Joins in this post. So first let us define what is join and then we will see different type of joins and their details.

Questions:

  • What is SQL joins?
  • What are the types of SQL joins?
  • Why do we need SQL joins?
  • Take home task on SQL Joins.
  • List of Interview Questions in SQL Joins.

Let us see what is SQL Joins?

SQL joins are the way of extracting some particular data in single query using multiple tables or same table. We can also say, we can leverage the referential ability of two interlinked table and get our desired data from both table using SQL query.

Not understood above lines? Leave them.. just remember, when you need different fields values in your output and you don't have all fields in a single table (Means Select * from table_1 do not have all the desired columns), then you need to join that table with other tables where those remaining fields resides. Now look at below picture...

SQL Joins - Sql Interviews Questions
 

Understood anything? No worries, let me explain now. Above two small box represents two tables, EMPLOYEE and DEPARTMENT. 

Department table is holding EMP_ID field similar to EMPLOYEE table. Now you could see a connection.

Suppose I want to get values from a query which will have EMP_ID, EMP_NAME, DEPT_NAME and SALARY. We could see, if we query only employee table, then we would not get department data. 

Because of this, we need to make some connection between two tables to get department name from department table.

Now we got why do we need to join tables right. Now we need to know how to join? Let us see next.

Again we will take above image and explain the query. You could see I have mentioned both table name after 'FROM' clause. This is the way to mention table name from which we need to get data. Now check the line after 'WHERE' clause. I have taken common field from both the tables, it is the way of joining. Although we can use different types of joins to join tables, we shall see them later.

Once both tables are joined, we can select our desired columns. Got it? Congratulations!!


Post a Comment

0 Comments