SQL Inner Join

SQL Inner join check join condition (including other comparison operator such as <, > etc) and create record set result that are combining columns value from the tables (two or more table).

SQL Inner join compare each row of Table A with each row of Table B which are satisfied the join predicate and return record set rows.

SQL Inner Join

SQL Inner join write two different way:

Example Table

Considering following category, product is our example table.

SQL> SELECT * FROM category;
CATEGORY_IDCATEGORY_NAME
1Mobiles
2Laptops
3Laptops
4Cameras
5Gaming
SQL> SELECT * FROM product;
CATEGORY_IDPRODUCT_NAME
1Nokia
1Samsung
2HP
2Dell
3Apple
4Nikon
NullPlaystation

Run it...   »

Explicit Inner Join

Explicit inner join use INNER JOIN keyword to specify the table to join. And ON keyword to specify join predicates condition. Consider following SQL inner join example that help you understanding,

Example

SQL> SELECT *
    FROM product INNER JOIN category
    ON product.category_id = category.category_id;

CATEGORY_ID PRODUCT_NAME          CATEGORY_ID CATEGORY_NAME
----------- --------------------- ----------- ---------------------
          1 Nokia                           1 Mobiles
          1 Samsung                         1 Mobiles
          2 HP                              2 Laptops
          2 Dell                            2 Laptops
          3 Apple                           3 Tablet
          4 Nikon                           4 Cameras

6 rows selected.

Run it...   »


Implicit Inner Join

Implicit inner join list of table join using FROM and WHERE clause keyword that are specify the tables and specify join predicates condition. Consider following SQL inner join example that help you understanding,

Example

SQL> SELECT *
    FROM product, category
    WHERE product.category_id = category.category_id;

CATEGORY_ID PRODUCT_NAME          CATEGORY_ID CATEGORY_NAME
----------- --------------------- ----------- ---------------------
          1 Nokia                           1 Mobiles
          1 Samsung                         1 Mobiles
          2 HP                              2 Laptops
          2 Dell                            2 Laptops
          3 Apple                           3 Tablet
          4 Nikon                           4 Cameras

6 rows selected.

Run it...   »