BigQuery'ye Giriş
Matthew Forrest
Field CTO
INNER JOIN: Değerler her iki tabloda da vardır.
LEFT JOIN: Sol tablonun tüm satırları, sağ tablo eşleşmeleri.
RIGHT JOIN: Sağ tablonun tüm satırları, sol tablo eşleşmeleri.
FULL JOIN: Her iki tablonun tüm satırları, eşleşenler ve eşleşmeyenler.
CROSS JOIN: Her satır, her iki tablodaki her satırla eşleşir.

Customers: sol tablo
Orders: sağ tablo
INNER JOIN: Eşleşen müşteriler ve siparişleri
LEFT JOIN: Siparişi olmasa da tüm müşteriler
RIGHT JOIN: Müşteri ID'si eksik olsa da tüm siparişler
FULL JOIN: Etkileşimi olmasa da tüm müşteriler ve tüm siparişler
CROSS JOIN: Koşulsuz, her siparişi her müşteriyle eşleştir
SELECT
c.customer_id, s.product_name
FROM customers c
-- INNER anahtar sözcüğü isteğe bağlıdır
JOIN sales_data s
ON c.customer_id = s.customer_id;
| customer_id | product_name |
|-------------|----------------------|
| 1 | Bluetooth Headphones |
| 2 | Running Shoes |
SELECT
c.customer_id, s.product_name
FROM customers c
LEFT JOIN sales_data s
ON c.customer_id = s.customer_id;
| customer_id | product_name |
|-------------|----------------------|
| 1 | Bluetooth Headphones |
| 2 | Running Shoes |
| 3 | null |
SELECT
c.customer_id, s.product_name
FROM customers c
RIGHT JOIN sales_data s
ON c.customer_id = s.customer_id;
| customer_id | product_name |
|-------------|----------------------|
| 1 | Bluetooth Headphones |
| 2 | Running Shoes |
| null | External Microphone |
SELECT
c.customer_id, s.product_name
FROM customers c
OUTER JOIN sales_data s
ON c.customer_id = s.customer_id;
| customer_id | product_name |
|-------------|----------------------|
| 1 | Bluetooth Headphones |
| 2 | Running Shoes |
| 3 | null |
| null | External Microphone |
SELECT
c.customer_id,
s.product_name,
-- Virgülle tablo adları eklemek
-- bir CROSS JOIN'dir
-- Sıra sol tabloya göre belirlenir,
-- burada "customers"
FROM customers c, sales_data s;
| customer_id | product_name |
|-------------|----------------------|
| 1 | Bluetooth Headphones |
| 1 | null |
| 2 | Bluetooth Headphones |
| 2 | null |
| 3 | null |
| 3 | Bluetooth Headphones |
SELECT
c.customer_id,
payments.method
FROM customers c,
UNNEST(
customers.payment_methods
) payments;
| customer_id | product_name |
|-------------|--------------|
| 1 | Visa |
| 1 | Mastercard |
| 1 | Venmo |
| 1 | Paypal |
| 2 | Amex |
| 2 | Visa |
BigQuery'ye Giriş