Difference between revisions of "JOIN"
Yvonnemilne (Talk | contribs) |
Helengeorge (Talk | contribs) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Create a new table by merging two existing ones together | Create a new table by merging two existing ones together | ||
Line 17: | Line 10: | ||
==See Also== | ==See Also== | ||
− | [[SET FILTER]], [[SET RELATION]] | + | [[SET DELETED]], [[SET FILTER]], [[SET RELATION]] |
Line 35: | Line 28: | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | select | + | select a |
+ | use patrons index events | ||
+ | select b | ||
+ | use addresses index names | ||
+ | select a | ||
+ | join with b to operalist for name = b->name | ||
</code> | </code> | ||
==Products== | ==Products== | ||
− | Recital | + | Recital Server, Recital |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
+ | [[Category:Table Basics]] | ||
+ | [[Category:Table Basics Commands]] |
Latest revision as of 16:58, 11 November 2009
Purpose
Create a new table by merging two existing ones together
Syntax
JOIN WITH <workarea | alias> TO < .dbf filename> | (<expC>) FOR <condition>
[FIELDS <field list>]
See Also
SET DELETED, SET FILTER, SET RELATION
Description
The JOIN command creates the new table <.dbf filename>, by merging records from the active table, and another table selected in another workarea. The filename can be substituted with a <expC>, enclosed in round brackets, which returns a valid filename. If no file extension is specified, then ".dbf" will be used.
The JOIN is accomplished by reading through the active table, one record at a time, and for each of the records, evaluating the specified FOR <condition> against every record in the WITH table. If the <condition> is .T., all of the specified fields are constructed into a record, and this record is written to the new table.
It should be noted that if SET FILTER TO is in effect, then any records from the active table which do not satisfy the filter condition, will be discarded, and not included in the join. Also, if SET DELETED ON is in effect, any records that are marked for deletion, will be discarded, and not included in the join.
If no FIELDS clause is specified the new table will consist of both sets of fields from both tables. If two field names are the same in both tables, the first one will be used, and the second one discarded. The fields will be combined up to the maximum field limit of 256.
FIELDS <field list>
The FIELDS clause allows you to specify which fields you want the new table to consist of. You may reference fields from both of the tables. If a field exists by the same name in both tables, then the field from the active table will be used unless you reference the field name with an alias ( ->) pointer.
Example
select a use patrons index events select b use addresses index names select a join with b to operalist for name = b->name
Products
Recital Server, Recital