SET SKIP Command Example

This example below finds all occurrences in three tables where each item in the first field are the same. It does this by using scanning the first table which has a relation into a second, which table has a relation into a third. The first table then does a SET SKIP for the other two tables. A SET SKIP on the second table has no effect. It affects only the table being scanned (replaced, etc.).  In the example, eight matches are found.

CLOSE DATABASES
* Creates parent table with values a and b in Name field
CREATE TABLE Parent FREE (Name C(1), Val C(10))
INSERT INTO Parent VALUES ('a', 'Parent.a1')
INSERT INTO Parent VALUES ('b', 'Parent.b1')

SELECT 0     && Child1 will have two a's and two b's
CREATE TABLE Child1 FREE (Name1 C(1), Val C(10))
INSERT INTO Child1 VALUES ('a', 'Child1.a1')
INSERT INTO Child1 VALUES ('b', 'Child1.b1')
INSERT INTO Child1 VALUES ('b', 'Child1.b2')
INSERT INTO Child1 VALUES ('a', 'Child1.a2')
INDEX ON Name1 TAG tagName   && The tag name is irrelevant

SELECT 0  && Child2 will have two a's and two b's
CREATE TABLE Child2 FREE (Name2 C(1), Val C(10))
INSERT INTO Child2 VALUES ('b', 'Child1.b1')
INSERT INTO Child2 VALUES ('b', 'Child1.b2')
INSERT INTO Child2 VALUES ('a', 'Child1.a1')
INSERT INTO Child2 VALUES ('a', 'Child1.a2')
INDEX ON Name2 TAG tagName     && The tag name is irrelevant

SELECT Child1
SET RELATION TO Name1 INTO Child2
SELECT Parent
SET RELATION TO Name INTO Child1
SET SKIP TO Child1, Child2 && Parent gets both skips.
           && Otherwise, only four record triplets 
           && would be listed.
SCAN ALL  && There will be eight triplets: four a's and four b's
   ? Parent.Val, Child1.Val, Child2.Val
ENDSCAN