>*** begin quote
>SELECT ... FROM origtable WHERE condition1 ;
> UNION SELECT ... FROM origtable WHERE condition2 ;
> UNION SELECT ... FROM origtable WHERE condition3 ;
> INTO TABLE newversion
>
>This will work as long as all 3 selects are taking the same fields from the original table, making it UNION compatible.Fred
>*** end quote
>
>Is there a limit to the complexity of the union-ed selects?
>
>Select
;
> Union Select ;
> Union Select ;
> Union Select ;
> Into DBF Output
>
>To: MikeH Re: 10 SQL calls - If the above statement is possible, it actually reduces the number of calls because the Mega-select will pull everything together in one 5-part step rather than 5 separate calls.
>
>"My sympathies for whoever inherits this code" <sg>
I *think* that the limit is 9 unions for a total of 10 tables. You could then group into intermediate SELECTS/UNIONS as many as needed.SELECT ... UNION SELECT ... INTO CURSOR set1
SELECT ... UNION SELECT ... INTO CURSOR set2
...
SELECT ... UNION SELECT ... INTO CURSOR setn
SELECT ... FROM set1 WHERE...
UNION ... FROM set2 WHERE...
I think you get the picture.