0
Şu anda veri depolayan iki tablom var. Bir ID değeri ile ilgilidir. Eşleşme olsa bile, ana değeri de dahil olmak üzere tüm değerleri tablodan nasıl döndürebilirim. İşte benim temel sorgum. İşte Left Join Return Birleştirme Değeri
Select MFG.mfgname, SS.subsysname
From Manufacturers MFG left join SubSystem SS
On MFG.id = SS.mfgid
Order by MFG.mfgname, SS.subsysname
tablolar
MFG Table
id mfgname
1 ABB
2 Siemens
3 Vipa
4 Visolux
SubSystem table
id mfgid subsysname
1 1 ABB Drives
2 1 ABB Robots
3 1 Advant OCS
4 2 Simatic S5
5 2 Simatic S7
6 3 Vipa System
Ve nihayet sonuçları ve istenen sonuçlardır.
Results
mfgname subsysname
ABB ABB Drives
ABB ABB Robots
ABB Advant OCS
Siemens Simatic S5
Siemens Simatic S7
Vipa Vipa System
Visolux NULL
Desired Results
mfgname subsysname
ABB NULL
ABB ABB Drives
ABB ABB Robots
ABB Advant OCS
Siemens NULL
Siemens Simatic S5
Siemens Simatic S7
Vipa NULL
Vipa Vipa System
Visolux NULL
İstenilen sonuçlar, ABB, Siemens ve Vipa mfgs'yi boş bir alt sistem adıyla da döndürecektir. Bu noktada değil. Umarım bu mantıklı!
Bu, "sol birleştirme" yi "iç birleştirme" ve "birleştirme" olarak "birleştirme" olarak değiştirirseniz, ayrı bir sıralama gereksiniminden kaçınarak biraz daha iyi bir performans sergileyebilir mi? –
, "subsysname" null değilse, iç birleştirmeyi ve tümünü birleştirebilirsiniz – JamieD77