Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Possible Bug in SQL Select WHERE clause in VFP7
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00563935
Message ID:
00564415
Views:
15
Thanks for passing this up the line.
I agree that using the "NOT IN (SELECT...)" is clearer and more ansi standard. However, when the join is on multiple fields, you then need to concatenate the multiple fields in the WHERE expression in your example. For example:

SELECT tbl1.*;
FROM tbl1;
WHERE tbl1.zipcode + tbl1.group + tbl1.type NOT IN ;
(select tbl2.zipcode + tbl2.group + tbl2.type FROM tbl2)

The above query would not be fully optimizable unless a key exists with the exact concatenated expression.

For this reason, we have decided to go with the HAVING ISNULL(tbl2.field) along with an outer JOIN, as in the example of my original post. As in:

SELECT tbl1.*;
FROM tbl1;
LEFT JOIN tbl2;
ON tbl1.zipcode = tbl2.zipcode and;
tbl1.group = tbl2.group and;
tbl1.type = tbl2.type;
HAVING ISNULL(tbl2.zipcode)

Any further insights appreciated.
Mark

>>I would recommend using the syntax below as it returns correct data and, IMO, the readability is better, i.e., it is easier to tell from the SELECT statement what the results will be.
>>
>>SELECT tbl1.*;
>>FROM tbl1;
>>WHERE tbl1.userid NOT in ;
>>(select tbl2.userid FROM tbl2)
>>
>Jim, for what it's worth, I checked this in SQL Server, and it disliked the HAVING syntax, to my surprise. I agree with you that the above syntax is clearer, though.
Previous
Reply
Map
View

Click here to load this message in the networking platform