Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need Assistance With A Query
Message
From
16/07/2004 22:00:30
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00925379
Message ID:
00925417
Views:
10
>Perfect! Thanks!

I wasn't sure whether this answered your question, but since that seems to be the case, let me add a few details.

Reposting my code:
select SchedLine.Length, Details.Type;
  from SchedLine join detail on SchedLine.SchedLineId = Details.SchedLineId
If one of the tables doesn't have an equivalent in the other table, the record won't be included in this example. For instance, suppose some data in the Details table doesn't have a valid SchedLineId number; the record will be omitted. To include all records in the Details table, just change JOIN to RIGHT JOIN (meaning, include all records in the table listed on the right side of the JOIN statement):
select SchedLine.Length, Details.Type;
  from SchedLine right join detail on SchedLine.SchedLineId = Details.SchedLineId
In the example, if a record in Details doens't have an equivalent in SchedLine, the corresponding fields (here: SchedLine.Length) will be .NULL. in the resulting cursor. If you need a valid value, you would usually use nvl(), something like this:
select nvl(SchedLine.Length, 00000), Details.Type;
  from SchedLine right join detail on SchedLine.SchedLineId = Details.SchedLineId
The 5 zeroes are to make sure the field has the correct width (assuming your field is defined as N(5,0)).

BTW, the possibility of an outer join (i.e., using LEFT, RIGHT or FULL in combination with JOIN) is an important reason to use the JOIN syntax, instead of the alternative WHERE (only option up to VFP 3).
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform