Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Union incompatibility error
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00411393
Message ID:
00411414
Vues:
10
>I get the message "SELECTs are not UNION compatible" when I run the following query:
>
>SELECT c.contact_id,d.issue_id AS Chiave FROM ai_core a ;
> JOIN cextern b ON a.id_agency==b.id_agency ;
> JOIN dcontact c ON b.extern_id==c.extern_id ;
> JOIN dissues d ON c.contact_id==d.contact_id ;
> WHERE c.staff_ext=2 ;
>UNION ;
>(SELECT c.contact_id,d.req_id AS Chiave FROM ai_core a ;
> JOIN cextern b ON a.id_agency==b.id_agency ;
> JOIN dcontact c ON b.extern_id==c.extern_id ;
> JOIN dreqs d ON c.contact_id==d.contact_id ;
> WHERE c.staff_ext=2)
>
>The UNION works fine without the second field, so the problem lies there and not in the individual joins. The first SELECT includes "issue_id" which is CHAR 8 and the second SELECT includes "req_id" which is CHAR 4. I am told that the second part of the union can have fields that are the came data type and equal to or smaller than the comparable fields in the first part, which is the case here. Since the query was bombing, I added the AS title "Chiave" for each, hoping that would make them closer to matching. That doesn't work either.
>
>Any idea why the second field(s) make the UNION fail?? I need to chain these together with others to make a mega report, but I can't seem to get off the ground.
>
>TIA
>
>Jim


UNION clauses follow these rules:
> You cannot use UNION to combine subqueries.
> Both SELECT commands must have the same number of columns in their query output.
> Each column in the query results of one SELECT must have the same data type and width as the corresponding column in the other SELECT.
> Only the final SELECT can have an ORDER BY clause, which must refer to output columns by number. If an ORDER BY clause is included, it affects the entire result.

Why not append 4 spaces to the second id field while selecting (id+' ')

Another thing,
You only have to name your fields in the first Select statement (Chiave)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform