INNER JOIN in Teradata

An inner join is the most common join operation used in applications and can be regarded as the default join-type. Inner join creates a new result table by combining column values of two tables (A and B) based upon the join-predicate.

The query compares each row of A with each row of B to find all pairs of rows which satisfy the join-predicate. When the join-predicate is satisfied, column values for each matched pair of rows of A and B are combined into a result row.

Consider the following two tables,
Employee table
LastNameDepartmentID
Robert31
Jones33
Steinberg33
Robinson34
Smith34
JohnNULL


Department table
DepartmentIDDepartmentName
31Sales
33Engineering
34Clerical
35Marketing

SELECT *
FROM employee
INNER JOIN department ON 
employee.DepartmentID = department.DepartmentID;


The queries given in the examples above will join the Employee and Department tables using the DepartmentID column of both tables. Where the DepartmentID of these tables match (i.e. the join-predicate is satisfied), the query will combine the LastName, DepartmentID and DepartmentName columns from the two tables into a result row. Where the DepartmentID does not match, no result row is generated.

Thus the result of the execution of either of the two queries above will be:
Employee.LastNameEmployee.DepartmentIDDepartment.DepartmentNameDepartment.DepartmentID
Robert34Clerical34
Jones33Engineering33
Smith34Clerical34
Steinberg33Engineering33
Rafferty31Sales31