PL/SQL Self Join

The PL/SQL SELF JOIN is joining a table to itself and returns rows when there is at least one match in the tables.

Phones table

PHONE_IDPHONE_NAMEBRAND_ID
1Galaxy Note Edge1
2N910 Galaxy Note 41
3Galaxy S5 Duos 4G1
4iPhone 5S2
5iPhone 6 Plus2
6930 Lumia3
7830 Lumia3

Self Join example

 
SELECT p.phone_id, p.phone_name, p2.brand_id
FROM phones p, phones p2
WHERE p.phone_id = p2.phone_id
ORDER BY p.brand_id;

Output

PHONE_IDPHONE_NAMEBRAND_ID
1Galaxy Note Edge1
2N910 Galaxy Note 41
3Galaxy S5 Duos 4G1
4iPhone 5S2
5iPhone 6 Plus2
6930 Lumia3
7830 Lumia3