SQL Joins

The SQL Joins are used to combine the data from two or more tables on the basis of some related columns of each.

Suppose, we want to join Peoples Table and Product Table to learn about the regional manager of each state. Let’s have a look at both the tables.

 

Demo Table –

Product Table

Category

Region

City

Country

Customer_ID

Customer_name

Office Supplies

Central

Chicago

United States

SM-20950

Suzanne McNair

Technology

East

New York City

United States

AH-10465

Amy Hunt

Office Supplies

East

New York City

United States

AH-10465

Amy Hunt

Office Supplies

East

Dover

United States

EP-13915

Emily Phan

Office Supplies

East

Dover

United States

EP-13915

Emily Phan

Technology

West

Aurora

United States

TP-21565

Tracy Poddar

Office Supplies

West

Aurora

United States

TP-21565

Tracy Poddar

Office Supplies

East

Long Beach

United States

AR-10825

Anthony Rawles

Office Supplies

West

Pasadena

United States

HA-14920

Helen Andreada

Furniture

West

Pasadena

United States

HA-14920

Helen Andreada

 

Manager Table

Region

Regional Manager

West

Sadie Pawthorne

East

Chuck Magee

Central

Roxanne Rodriguez

South

Fred Suzuki

As in both the tables, we have a “Region” in the same column. This field can help to join both the table. There can be multiple joins in a single statement.

The joins are performed in the WHERE Clause. We can use different operators such as =, <, >, <>, <=, >=, !=, BETWEEN, etc. to join the table, but the most commonly used operator is “=”.

  • Types of Joins

These are different types of joins available in SQL.

1. Inner Join – It returns the records that are matching in both tables.

2. Full Outer Join or Full Join – It returns all the records when there is a match in either of the tables.

3. Left Outer Join or Left Join – It returns all the records from only the table situated to the Left.

4. Right Outer Join or Right Join – It returns all the records from only the table situated to the Right.

5. Self Join – This join is used when the table has a join to itself.

6. Cross Join – This join returns the records by having a Cartesian product of records from the joined tables.

Follow us on TwitterFacebookLinkedin, and Tableau Public to stay updated with our latest blog and what’s new in Tableau.

Automate data analysis pipeline and create report ready dashboards

If you are looking forward to getting your data pipeline built and setting up the dashboard for business intelligence, book a call now from here.

#analytics #data #business #artificialintelligence #machinelearning #startup #deeplearning #deeplearning #datascience #ai #growth #dataanalytics #india #datascientist #powerbi #dataanalysis #tableau #SQL #businessanalytics #businessanalyst #businessandmanagement #dataanalyst #businessanalysis #analyst #analysis #powerbideveloper #powerbidesktop #letsviz