Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL join with empty data in one table
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00392660
Message ID:
00392698
Views:
11
>Hello,
>I need to make an SQL join of two tables, while data is missing in one of the two tables. Normally when I SELECT * FROM Table1 LEFT OUTER JOIN Table2 ON This=That , this is no problem, but in this case, I have in the WHERE clause something like:
>
>SELECT * FROM Companies Co LEFT OUTER JOIN Sales Sa ON Co.keyvalue = Sa.keybedra WHERE Sa.Price > 0 INTO CURSOR BadResult
>
>This results in a cursor that excludes all companies that have no corresponding records in the sales table, because of the Price>0 clause.
>What can I do about this? Changing the cursor name into GoodResult doesn't help either.

Try:
SELECT * ;
   FROM Companies Co ;
   LEFT OUTER JOIN Sales Sa ;
      ON Co.KeyValue = Sa.keyBedra AND ;
         Sa.Price > 0 ;
   INTO CURSOR GoodResult
My blog
My consulting page
My home page

Member of the Trim Your Auto-Quote Campaign!
What's another word for thesaurus?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform