Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Controlling select field names
Message
De
27/05/2010 14:43:53
 
 
À
07/05/2010 18:39:54
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01463481
Message ID:
01466296
Vues:
36
>>>>When SELECTing from 2 or more tables with identical field names like this:
SELECT * ;
>>>>FROM taz2005 a;
>>>>inner JOIN taz2010 c ON a.taz = c.taz
>>>>the result field names have an "_a" appended to them for the first table and a "_b" appended for the second table. I would like them to come up with "_2005" appended for the first table and "_2010" appended for the second table. Is there an easy way to do this without writing a ton of code to parse and rename the fields?
>>>>
>>>>Secondly, I'd like the fields from the two tables to be collated so like fields would appear next to each other like this:
>>>>
>>>>HH_2005, HH_2010, etc.
>>>>
>>>>Same question, is there an easy way to do this? I know about SET FIELDS, but the issue here is each table has 40+ fields and we don't know how many, or which, tables may be joined in advance. I am trying to move my people out of excel and into a database but the complexity is daunting to them.
>>>>
>>>>Thanks for any thoughts on this.
>>>
>>>The only way (and the right way) is to explicitly list every field with the correct alias.
>>
>>Thanks Naomi. That's what I was afraid of. So I guess I will have to write a loop to programmatically write the select statement. :(
>
>Create a cursor with field names, aFields() then append from array for each table, then generate the SQL statement from that cursor. Not the most elegant way to do it, but there it is. Sorting... you may try to cook up something based on the order of fields in the first table, maybe assigning an extra field for the first table, then ordering by field name, then applying that marker to all other fields of the same name... couple of hours of fun.

Thanks Dragan. This one has been set aside for a while when I have more time.:)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform