Home > Database > SQL Join – Right Join

SQL Join – Right Join

September 3, 2013 Leave a comment Go to comments

Right Join keyword mengembalikan semua row pada table B ( table setelah keyword RIGHT JOIN ) yang cocok dengan row pada table A. Jika pasangannya tidak ditemukan, tabel A berisi NULL.

Syntax:

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

Diagram venn Right join

Right Join

Right Join

Berikut ini contoh right join :

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

Right join statement:

SELECT customers.id, customers.name, customers.address, orders.oid, orders.customer_id, orders.amount
FROM customers RIGHT JOIN orders ON customers.id = orders.customer_id

Result:

Result

Semoga bermanfaat.

Referensi : Dari berbagai sumber.

  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: