Middle
LEFT JOIN kullanmanın gerekli olduğu somut bir örnek verin
sobes.tech yapay zeka
AI'dan gelen yanıt
LEFT JOIN, sol Records from the left table and the matching records from the right table, and if there are no matches, the fields from the right will be NULL kullanılır.
Örneğin, customers ve orders adlı tablolar var. Tüm müşterileri ve siparişlerini göstermek istiyorsanız, hatta henüz sipariş vermemiş müşterileri de dahil etmek için LEFT JOIN kullanılır:
SELECT customers.id, customers.name, orders.order_id
FROM customers
LEFT JOIN orders ON customers.id = orders.customer_id;
Bu şekilde, tüm müşteri listesi alınır ve siparişleri olmayanlar için orders tablosundan alanlar NULL olur.