Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL - Select
Message
From
29/01/2003 14:41:25
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00746724
Message ID:
00746845
Views:
24
>>SELECT Projectid, ;
>> a.oecname AS ownname,;
>> b.oecname AS engname,;
>> c.oecname AS conname ;
>> FROM curTemp1;
>> JOIN tmpoec a ON curTemp1.Owner = a.oecid;
>> JOIN tmpoec b ON curTemp1.Engineer = b.oecid;
>> JOIN tmpoec c ON curTemp1.Contractor = b.oecid;
>> INTO CURSOR curTEMP


Of course his large table problem could be a result of incorrectly aliasing the third line of the join; see b.oecid twice. Also using a LEFT JOIN will ensure he does not lose any project records due to missing ID records. I personally like to use "LEFT JOIN", "INNER JOIN", "RIGHT JOIN" and "FULL JOIN" because it helps describe what the results will be.


SELECT x.Projectid, a.oecname AS ownname, b.oecname AS engname, c.oecname AS conname ;
FROM curTemp1 x;
LEFT JOIN tmpoec a ON x.Owner = a.oecid;
LEFT JOIN tmpoec b ON x.Engineer = b.oecid;
LEFT JOIN tmpoec c ON x.Contractor = c.oecid;
INTO CURSOR curTEMP NOFILTER && or READWRITE if using VFP7


I always use single letters to alias my SQL statements and I always start from "a". Not very descriptive, but with less characters to look at the SQL seems simpler to me. Personal preference I would think. I have never heard of a-j causing problems.
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform