INNER JOIN
The INNER JOIN function selects records that have matching values in both tables.
You can use an inner join in a SELECT statement to retrieve only the rows that satisfy the join conditions on every specified table. You can request an inner join, by running a SELECT statement in which you specify the tables that you want to join the FROM clause and specify a WHERE clause or an ON clause to indicate the join condition. The join condition can be any simple or compound search condition that does not contain a sub-query reference.
In the simplest type of inner join, the join condition is column1=column2.
Example:
The following example joins the records with similar employee name from the tables EMPLOYEE and EMPL_COMP.
SELECT A.EMPL_NAME, B.EMPL_ID, A.DEPT, A.INDUSTRY, B.COMPANY, B.LOCATION
FROM EMPLOYEE A
INNER JOIN EMPL_COMP B
ON
A.EMPL_NAME = B.EMPL_NAME "
The above example returns the following.
EMPL_NAME | EMPL_ID | DEPT | INDUSTRY | COMPANY | LOCATION |
---|---|---|---|---|---|
ELICA | 2 | CUST SUPER | RETAIL | STANLEY INC. | TX |
ELICA | 2 | STANLEY INC. | TX |