Focal Point
Joins

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1331071432

June 25, 2007, 11:23 AM
<Edgare>
Joins
Hi

I need clarification on types of joins.

Can you please provide samples of
1 to 1 join
1 to many join
Left and Right Joins.

I am using vms focus.

Thanks!
June 25, 2007, 11:33 AM
Leah
1 to 1 join, means for file1 joined to file2 there is only one record in file2 for file1, or there may be none. 0 to many records in file2 for file1.

When you say left and right? I only recall left, means you have an inner or outer join, if an outer then there could be a possiblility of 0 records in file2 for file1, but you want data from file1 any way. Inner, must have data in file2 for file1.

Someone out there may have a nicer way of explaining.

It's like saying a family can have 0 or many children, but children always have parents somewhere.


Leah
June 25, 2007, 11:52 AM
<Edgare>
Leah you got it all right but could you please provide the code for each type?
June 25, 2007, 12:01 PM
Leah
Are you using the developer tool? It handles it for you.

Otherwise, I'll see what I can come up with with IB's test date.


Leah
June 25, 2007, 12:08 PM
<Edgare>
I am not using dev version i think you are referring to webfocus. I am on VMS focus which dosent have gui of any kind ... basically ...
need to type in

join fielda in tbla to fieldb in tblb as a ...
June 25, 2007, 12:09 PM
Leah
Note all developer studio tool generated (vs 7.6.1)

Multiple

JOIN
EMPDATA.EMPDATA.PIN IN EMPDATA TO MULTIPLE EDUCFILE.ATTNDSEG.EMP_ID IN EDUCFILE
AS J0
END

Single

JOIN
EMPDATA.EMPDATA.PIN IN EMPDATA TO EDUCFILE.ATTNDSEG.EMP_ID IN EDUCFILE
AS J0
END

Inner

JOIN
EMPDATA.EMPDATA.PIN IN EMPDATA TO MULTIPLE EDUCFILE.ATTNDSEG.EMP_ID IN EDUCFILE
AS J0
END

left outer

JOIN
LEFT_OUTER EMPDATA.EMPDATA.PIN IN EMPDATA TO MULTIPLE EDUCFILE.ATTNDSEG.EMP_ID
IN EDUCFILE AS J0
END


In my world we don't add all the extras if straight code so for say single would be


JOIN
PIN IN EMPDATA TO EMP_ID IN EDUCFILE
AS J0
END

Note this would be if not a focus data base, I just deleted the tagging.


Leah
June 25, 2007, 12:15 PM
Leah
Let me think back to when our student system was flat so to speak. We'd have student attribute records and student term records so:

JOIN
STU_ID IN AARTTBL TO ALL STU_ID IN RTRTTBL AS J1
END
would return all records.
ALL becomes MULTIPLE in the world of 7....

JOIN
STU_ID IN AARTTBL TO STU_ID IN RTRTTBL AS J1
END

would return first term record.

Also, don't know as you can use left outer in your version. May have to use the SET ALL ON option


Leah