Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unexpected query result
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00483532
Message ID:
00483585
Views:
14
Ok. First Off, my experience with SQL statements in VFP has given me the following insight that might help you understand what's going on:

When you issue Query 1, VFP is looking for all records in table db1 where fld2a is equal to the current value of what's in fld2b from db2. The same sort of logic holds true for the second clause.

So basically, you're telling VFP to return all records from both tables where certain fields in db1 match what's in the fields for the current record in db2.

I know most people say that for an INNER JOIN you don't have to specify it in the FROM clause of a SQL Select statement. However, my experience has been that when you want to join to tables in a query, you better indicate it in the FROM clause.

If all you're trying to do is return matching records from db1 that match the current values of the current record in db2, then you can omit db2 from the FROM clause.

HTH

>Again without the typo -
>
>Query 1 :
>
>select * from db1 a, db2 b where (a.fld2a=b.fld2b) AND (trim(a.fld1a)=trim(b.fld1b))
>
>
>Query 2 :
>
>select * from db1 a, db2 b where (a.fld2a=b.fld2b) AND (trim(a.fld1a)=trim(b.fld1b)) AND (a.fld2a=b.fld2b)
>
>
>Query 3 :
>
>select * from db1 a, db2 b where (trim(a.fld1a)=trim(b.fld1b)) AND (a.fld2a=b.fld2b)
>
>
>In the first case, I could 1 record returned. In the second 2 I get nothing returned.
>
>In all three, I would expect the same result, but two records returned (set exact is off, so ABCD should match ABC, which it does if I test on the command line).
Travis Vandersypen
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform