Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looking for a better way
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00305584
Message ID:
00305589
Vues:
25
Hi Steve,

Sure there is - what you're looking for is a join.

Say your table that you're reporting from is called ReportBase and has a field called CarMakeID (which contains the codes for the make of the car)

Set up a lookup table (called LookupCarMake) with the fields CarMakeID and CarMakeDescription, then use the SQL
SELECT ReportBase.*, LookupCarMake.CarMakeDescription ;
  FROM ReportBase ;
  INNER JOIN LookupCarMake on ReportBase.CarMakeID = LookupCarMake.CarMakeID ;
  INTO CURSOR JoindReport
Now do the report based on the cursor and away you go.

You can also do this using SET RELATION (which saves making the cursor), but unless the report is based on a very large table, I reckon the simplicity of the SQL Join outweighs the possible performance implications.

Cheers,

Andrew

>I am doing a SELECT - SQL command that gathers all of my data for my report. But is there a way within the SQL command that I can translate some of the data that has codes to represent data which is really strings of text?
>
>For example my report shows a column of codes as in 1, 3, 6, 4, 6
>1 = Ford
>2 = Chevy
>3 = Buick
>4 = Pontiac
>5 = Cadillac
>6 = Chrysler
>
>Is there an easy way during the SELECT to translate the codes on the fly so I don't have to play games in the report or before the report to translate the codes? So the word Ford prints instead of the code 1 and so on.
>
>I am simply looking for a shortcut or better way. Thanks for your able-bodied assistance ahead of time.


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform