Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Photoshopgod
Starting Member
10 Posts |
Posted - 2004-07-15 : 08:57:12
|
Hi all,I have an sql statement that reads;strsql = "SELECT * FROM tblCustomers tblCustomers left join tblParents tblParents on tblParents.custID = tblCustomers.custID WHERE tblCustomers.custID = " & tkeyI have two other tables I would like added to this statement. Both may or may not have information. Lets call them tbl3 and tbl4. What is the best way to go about this? Can you left join multiple tables with few problems? I'm still learning sql so any feedback would be appreciated. Thanks in advance. |
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2004-07-15 : 09:35:04
|
fyi....the purpose of an alias...is to make it shorter to write code....and sometimes to assist readability....your double "tblCustomers tblCustomers " could be made shorter by using the style "tblCustomers a"and thus strsql = "SELECT * FROM tblCustomers tblCustomers left join tblParents tblParents on tblParents.custID = tblCustomers.custID WHERE tblCustomers.custID = " & tkeystrsql = "SELECT * FROM tblCustomers a left join tblParents b on a.custID = b.custID WHERE a.custID = " & tkeywhen you get into 8/9/10 tables...you might appreciate the shortcut.onto your main question....yes you can keep on left joining....just make sure you understand the nature of their anchor columns...ie the tables which provide the columns in the ON clauses |
 |
|
Photoshopgod
Starting Member
10 Posts |
Posted - 2004-07-15 : 11:59:01
|
Hi AndrewMurphy,Thanks for the quick reply. Also thanks for the fyi. That will help because this might end up being about 6 ot 7 tables. |
 |
|
|
|
|