>SELECT dt2.fld1, t2.fld4, t1.fld3 ; > FROM table2 t2 ; > JOIN (SELECT DISTINCT fld1 FROM table1) dt2 ON .T. ; > LEFT JOIN table1 t1 ON t1.fld1=dt2.fld1 AND t1.fld2 = t2.fld4 >>
>>>CLOSE DATABASES >>> >>>CREATE CURSOR table1 (fld1 C(2), fld2 C(2), fld3 I) >>>INSERT INTO table1 VALUES ("A1", "P1", 1) >>>INSERT INTO table1 VALUES ("A1", "P2", 2) >>>INSERT INTO table1 VALUES ("B1", "P3", 3) >>>INSERT INTO table1 VALUES ("B1", "P4", 4) >>> >>>CREATE CURSOR table2 (fld4 C(2)) >>>INSERT INTO table2 VALUES ("P1") >>>INSERT INTO table2 VALUES ("P2") >>>INSERT INTO table2 VALUES ("P3") >>>INSERT INTO table2 VALUES ("P4") >>>INSERT INTO table2 VALUES ("P5") >>>INSERT INTO table2 VALUES ("P6") >>>INSERT INTO table2 VALUES ("P7") >>>INSERT INTO table2 VALUES ("P8") >>> >>>SELECT DISTINCT fld1 FROM table1 INTO CURSOR dt2 NOFILTER >>> >>>SELECT * FROM table2, dt2 INTO CURSOR td3 >>> >>>SELECT td3.*, t1.fld3 FROM td3 LEFT JOIN table1 t1 ON t1.fld1=td3.fld1 AND t1.fld2 = td3.fld4 >>>>>>