Skip to content

nidhica/task5-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task 5 – SQL Joins (SQL Developer Internship)

Objective

Learn how to combine data from multiple tables using different types of SQL Joins.
This task demonstrates INNER, LEFT, RIGHT, FULL, CROSS, NATURAL, SELF joins along with answers to interview-style questions.

1. Difference between INNER and LEFT JOIN?

Inner only rows that have matching values in both tables. Left join all rows from the left table, and matching rows from the right table. If no match, right-side columns are null.

2. What is a FULL OUTER JOIN?

Combines the results of both LEFT JOIN and RIGHT JOIN and returns all rows from both tables, matched where possible, otherwise NULL where no match exists.

3. Can joins be nested?

Yes joins can be nested.

4. How to join more than 2 tables?

We can join more than two tables by using multiple join statements and link the new table to the previously joined table.

5. What is a cross join?

It gives cartesian product of two tables.

6. What is a natural join?

It matches the columns with the same name in both tables automatically.

7. Can you join tables without foreign key?

Yes tables can be joined without foreign key and any columns can be used.

8. What is a self-join?

When a table is joined with itself is called self-join.

9. What causes Cartesian product?

It is when join is performed without any condition.

10. How to optimize joins?

Create indexes on join columns. Using only required columns. Choosing the right join type. Use EXPLAIN to analyze performance. Reduce data early with filters.

Screenshots

1. Inner Join

Inner join

2. Left Join

Left join

3. Full Outer Join

Full outer join

4. Joining Two Tables

Inner join

5. Cross Join

Cross join

6. Natural Join

Full outer join

7. Self Join

Self join

8. Cartesian Product

Cartesian Product

9. Optimizing query with index

Query optimization

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors