Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I avoid explicitly naming columns in sql query?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00680574
Message ID:
00680684
Vues:
24
The original table after SQL has fields like
PropID_a, SiteID_a, ..., PropID_b, SiteID_b

The result of the program is:

PropID, SiteID, PropID_b, SiteID_b

I'm too tired to look for this program right now (still at work). I'll send the code on Monday.

>Nadya,
>
>How can a table have multiple fields with the same name?
>
>Just curious to know, how do you do this in your post-processing code?
>
>>For cases like this we have a special post-processing altering table structure code. It changes all columns with _a to just fieldname. Send me a letter to work, I'll send you the code on Monday.
>>
>>Could be a Wish List for Toledo.
>>
>>>In sql server/transact sql when a query such as:
>>>
>>>select * from sosord, sostrs where sosord.csono=sostrs.csono
>>>
>>>is executed, the key value appears once in the result set as csono. In vfp you end up with csono_a, and csono_b.
>>>
>>>If I want my cursor result to be 'clean' and not have the underscores, then I need to explicitly name all the columns, and include the key from only one of the tables, once. But this results in very long query statements. I wrote a little routine to retrieve all of the column names for a given table into a formatted select string, and put it on the clipboard. This helps speed things up, but I still would be able to use select *.
>>>
>>>Is there any syntax, or trick that I can use to shorten my select statements. E.g. I wish there was a keyword like
>>>
>>>select * from sosord, sostrs where sosord.csono=sostrs.csono NODUPLICATEKEYVALUES
>>>
>>>Is there a specific reason why VFP's sql is implemented so differently than TRANSACT-SQL in such a fundamental area?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform