Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: SELECT UNION bad fieldname with a order pass
Message
 
 
À
06/09/2005 13:21:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Divers
Thread ID:
01046830
Message ID:
01047104
Vues:
6
Fabio

>I think that you have not understood where the problem is.

I understood exactly what you are calling a bug.

>Are you happy that these two queries return a final cursor with different column name?

As I said before I wouldn't use inconsistent column names in my query and complain when the SQL query engine decides to use one or the other depending on how it accomplishes the task.

>
>* this return X
>SELECT F1 X FROM T1;
>UNION ALL;
>SELECT F2 Y FROM T2
>
>* this return Y
>SELECT F1 X FROM T1;
>UNION ;
>SELECT F2 Y FROM T2
>
I'd write the queries like this and be happy all day long that I got consistent results:
* this returns X
SELECT F1 X FROM T1;
UNION ALL;
SELECT F2 FROM T2

* this returns X
SELECT F1 X FROM T1;
UNION ;
SELECT F2 FROM T2

* this returns X
SELECT F1 X FROM T1;
UNION ALL;
SELECT F2 X FROM T2

* this returns X
SELECT F1 X FROM T1;
UNION ;
SELECT F2 X FROM T2
It just doesn't make much sense that you'd give alternate aliases (X in one statement and Y in another) to the columns between the select statements. For non-trivial queries it would be much harder for another developer following behind you to understand/modify/debug/ the SQL code.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform