>>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