Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL To select from Multiple Tables
Message
 
 
To
03/04/2013 11:43:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01569456
Message ID:
01569916
Views:
50
>I have Gone Through the Tutorial Provided in the Link. Now I am able to use LEFT JOIN to Merge Two Tables as per my Requirement. I am using this Command
>
>
>Select A.FileName,A.InvoiceNo,A.Phoneno,A.N_month,A.Amtpayable,M.ExCHANGE,M.FIRSTNAME,M.LASTNAME,M.INSTALDATE
 FROM AMOUNTPAYABLE A LEFT JOIN MASTER M ON A.FileName=M.AccountNo
>
>
>But Now I have another Table and yet another. In Such cases How will I now Add. Suppose I need Column PREVBALAMT From PREVBAL. PREVBAL has also the same common filed FIlename. What Would be the revised SQL For adding Multiple Tables.
>
>
>
Just keep LEFT JOINing to your other tables e.g.
Select A.FileName,A.InvoiceNo,A.Phoneno,A.N_month,A.Amtpayable,Mstr.ExCHANGE,Mstr.FIRSTNAME,Mstr.LASTNAME,Mstr.INSTALDATE
 FROM AMOUNTPAYABLE A LEFT JOIN MASTER Mstr ON A.FileName=Mstr.AccountNo
LEFT JOIN PrevBal PB ON A.FileName = PB.FileName
Also, it's a bit dangerous to use a-m letters as aliases of the tables in the select statement when we're talking about VFP data. You may better use 2 letter aliases.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform