Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One SPT cursor to be used in another SPT
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01135239
Message ID:
01135249
Views:
22
>Yes the first one worked perfectly. I was able to reuse the SQL statement, which was important just in case the SQL #1 should be ever changed. I had first tried a LEFT JOIN but one of the fields would not allow a NULL value so I did a simple JOIN will it affect the result set?

Changing JOIN will affect the result.
With LEFT JOIN you will get all records from Main table and only matching records from joined table
With simple JOIN (default is INNER) you get ONLY these records from main table that have coresponding records in second i.e.:
FirstTable
Id     Fld1
Int    C(20)
--------------
1      Rec1
2      Rec2
3      Rec3
4      Rec4


SecondTable
Id     FT_FK Fld3
Int    Int   C(20)
-----------------
1       1    SecTblRec1
2       2    SecTblRec2
1. Left Join:
SELECT FT.Id, FT.Fld1, ST.Id AS StId, St.Fld3
       FROM FirstTable Ft
LEFT JOIN SecondTable St ON Ft.Id = St.Ft_FK

*** Result will be:
Id     Fld1  StId   Fld3
Int    C(20) Int    C(20) 
--------------------------
1      Rec1   1     SecTblRec1
2      Rec2   2     SecTblRec2
3      Rec3  NULL   NULL
4      Rec4  NULL   NULL
2. [INNER] Join:
SELECT FT.Id, FT.Fld1, ST.Id AS StId, St.Fld3
       FROM FirstTable Ft
JOIN SecondTable St ON Ft.Id = St.Ft_FK

*** Result will be:
Id     Fld1  StId   Fld3
Int    C(20) Int    C(20) 
--------------------------
1      Rec1   1     SecTblRec1
2      Rec2   2     SecTblRec2
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform