Hi Guys,
I have here an illustration of the scenario.
I needed to select query using Table1 to get details of the other tables because it has key for the other tables.
Table1 - | Key1 | Key2 | Key3 | Key4 | Key5
Table2 - | Key1 | Key1Detail1 | Key1Detail2 | Key1Detail3
Table3 - | Key2 | Key2Detail1 | Key2Detail2 | Key2Detail3
Table4 - | Key3 | Key3Detail1 | Key3Detail2 | Key3Detail3
Table5 - | Key4 | Key4Detail1 | Key4Detail2 | Key4Detail3
What I did was I used "LEFT JOIN" to get the other table in a single query. Because I want it to be optimized like that.
But my question is am I doing it right? Is it really optimized? Or there is another way of doing this? The best practice for this?
Code: SELECT a.*,b.*,c.*,d.*,e.* FROM Table1 a LEFT JOIN Table2 b on a.Key1 = b.Key1 LEFT JOIN Table3 c on a.Key2 = c.Key2 LEFT JOIN Table4 d on a.Key3 = d.Key3 LEFT JOIN Table5 e on a.Key4 = e.Key4 WHERE a.Key5 = 'ETC'
Thanks in advance MSDN pips