SQL INNER JOIN
SQL INNER JOIN write two different way: explicit inner join and implicit 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 write two different way:
Example Table
Considering following category
, product
is our example table.
|
|
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.
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.