Home > Database > SQL Join – Full Join

SQL Join – Full Join

September 4, 2013 Leave a comment Go to comments

Full Join keyword mengembalikan semua row pada table A ( table kiri ) dan table B ( table kanan ). Full join merupakan gabungan dari result left join dan right join.

Syntax :

SELECT column_name(s) FROM tableA FULL JOIN tableB ON tableA.column_name = tableB.column_name

Diagram venn Full join:

Full Join

Full Join

Berikut ini contoh full join :

Masih menggunakan table yang sama pada post SQL Join – Left Join ( Customers dan Orders Table )

Full join statement :

SELECT customers.id, customers.name, orders.oid, orders.customer_id
FROM customers
RIGHT JOIN orders ON customers.id = orders.customer_id
UNION ALL
SELECT customers.id, customers.name, orders.oid, orders.customer_id
FROM customers
LEFT JOIN orders ON customers.id = orders.customer_id

Result:

Result

Result

Database MySQL tidak mendukung full join, jadi saya menggunakan keyword union all.

Semoga bermanfaat.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: