Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Append from SQL cursor
Message
De
10/01/2000 09:36:01
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/01/2000 17:05:27
Michael Dougherty
Progressive Business Publications
Malvern, Pennsylvanie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00314771
Message ID:
00315442
Vues:
44
>>I tried "Select * from a,b,c into cursor qcOutput", but i ended up with 27 records instead of 9. I know the extra records are partially because i have no join condition. What is the syntax to fix this?
>
>I figured it out, use: "Select * from A Union Sele * from B Union Sele * from C into qcOutput"
>
>Multiple "Union"s must get pretty ugly in a single statement. In my case, i'll only be joining 4 similar tables. Is there any price (beyond readability) to an N-Union Select statement for large values of N? (my boss and I were discussing how mysteriously SQL takes a cumbersome line of code and miraculously returns a table full of data- often what you wanted, but sometimes not)


In first case every record matched with the other giving you fcount(A), fcount(B), fcount(C) fields and reccount(A)*reccount(B)*reccount(C) records.
Union is another beast. As it name suggest it "unions" the result as if you appended from all those 3 tables. If you don't use "union all" then it also eliminates duplicates in the result set. To be able to use it tables (more truely selected fiedls) should have the same structure. Each union is accepted as a subquery and for large valuse of N you have a limitation to 10. It always returns what you want it from but that might not be what you want. In cases do not forget to try "FORCE" clause to force SQL to make joins in the order you specify.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform