>I have an SQL union on free tables that fails when one of the subqueries is empty:
>
>
> SELECT * FROM ROOMBOOK ;
> WHERE BETWEEN(ROOM_DATE, STARTDATE, ENDDATE) .AND. ;
> !EMPTY(FOLIO_NBR) ;
> UNION ;
> SELECT * FROM RMBKHST ;
> WHERE BETWEEN(ROOM_DATE, STARTDATE, ENDDATE) .AND. ;
> !EMPTY(FOLIO_NBR) ;
> ORDER BY ROOM_DATE, ROOM_NBR ;
> INTO CURSOR C_ROOMBOOK READWRITE
>
>
>If either of the tables have no matching entries, then I get an error "SELECTs are not UNION compatible. Number of fields do not match."
>
>Can I make this work?
Weird.
Have you tried explicitly listing the columns (it's a good practice, BTW)?
If it's not broken, fix it until it is.
My Blog