Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LEFT JOIN vs FULL JOIN
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01514564
Message ID:
01514666
Vues:
43
>>>Hi,
>>>
>>>I am working on joining two tables into a query and it looks like Selecting From Table1 and FULL JOIN Table2 is the same as Select from Table2 and LEFT JOINT Table1. Is there advantage using one or the other? The tables/queries Table1 and Table2 are very small (less than 100 records) so I am not sure there would be difference in speed. But I am wondering if one is more practical then the other. TIA.
>>
>>The results returtned by LEFT JOIN vs. FULL JOIN are different when you have non-matching records in both tables. If you only have, say, records in Table1 and some of them don't have matching records in Table2, but the opposite is not true, then LEFT JOIN and FULL JOIN will return the exactly same result and if you can anticipate this situation, it's better to use LEFT JOIN then.
>
>Thank you again for your input. I was too tired last night to really understand what you are saying. Today I have played with some sample data, trying difference scenarios, and I choose to go with FULL JOIN. The reason is that if Table2 has record(s) not matching to the records in Table1, the LEFT JOIN selects this record(s) but the value in the column on which the LEFT JOIN is built gets NULL value. The other way, with FULL JOIN, the column on which the JOIN is built always gets the value (correct value). This is important to me.

I think you're still missing the point.

If table2 has some records that don't have corresponding records in table1, then
select Table2.* from Table2 LEFT JOIN Table1 ...
Here you need to start with the table that may not have corresponding records in another table.

FULL JOIN is only used when the situation is symmetrical, e.g. you may have non-matching records in either of the tables. Then and only then it make sense to use FULL JOIN.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform