PL/SQL Left Join

The PL/SQL LEFT JOIN return all rows from the left table, although there are no matches in the right table.

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

Phone_brands table

BRAND_IDNAME
1Samsung
2Apple
3Nokia
4HTC
5BlackBerry

Left Join example

 
SELECT b.brand_id, b.name as brand, p.phone_name
FROM phone_brands b LEFT JOIN phones p
ON b.brand_id=p.brand_id
ORDER BY b.brand_id;

Output

BRAND_IDBRANDPHONE_NAME
1SamsungGalaxy Note Edge
1SamsungN910 Galaxy Note 4
1SamsungGalaxy S5 Duos 4G
2AppleiPhone 5S
2AppleiPhone 6 Plus
3Nokia930 Lumia
3Nokia830 Lumia
4HTC(null)
5BlackBerry(null)