Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query Help part 1
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00952380
Message ID:
00952422
Views:
9
Very strange. I read the help now & it said "INNER JOIN specifies that the query result contain only rows from a table that match one or more rows in another table", So the first result is strange. May I ask Yo how many records You expect?

Here my test prog
SET SAFETY OFF
CREATE DBF TABLE1 (cust_no N(5), field1 C(5), field2 C(6))
CREATE DBF TABLE2 (cust_no N(5), field3 C(15), field4 C(15))
FOR asd = 1 TO 65
    INSERT INTO Table1 (cust_no, field1, field2) VALUES (asd, "FLD"+TRANSFORM(asd),"FLD1"+TRANSFORM(asd))
NEXT
SELECT Table1
SELECT Table1.cust_no, Table1.Field1, Table1.field2, IIF(ALLTRIM(Table2.Field3)=="Collet",Field4,SPACE(15)), Table2.Field3;
       FROM Table1;
       INNER JOIN Table2 ON table1.cust_no == table2.cust_no;
       WHERE Table1.cust_no # 0;
       INTO CURSOR cTte

BROW &&  cTte has No records       


FOR asd = 1 TO 64
    FOR asd1 = 1 TO 1000
         INSERT INTO Table2 (cust_no, field3, field4) VALUES (asd,;
                                                              IIF(asd1>500,"Collet","FLD"+TRANSFORM(asd1)),;
                                                              IIF(asd1>500,"FLD1"+TRANSFORM(asd1),""))
    NEXT
NEXT
INSERT INTO Table2 (cust_no, field3, field4) VALUES (77, "77", "77") && This record is to make sure that not all the records from Table2 go to cTte


SELECT Table2
SELECT Table1.cust_no, Table1.Field1, Table1.field2, IIF(ALLTRIM(Table2.Field3)=="Collet",Field4,SPACE(15)), Table2.Field3;
       FROM Table1;
       FULL JOIN Table2 ON table1.cust_no == table2.cust_no;
       WHERE Table1.cust_no # 0;
       INTO CURSOR cTte

BROWSE && 64001 records as I expected, ALL records from table1 & matching all records from table2
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform