Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you use IIF(a,b,c) in a SELECT statement?
Message
De
13/11/2000 17:03:12
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00440969
Message ID:
00441296
Vues:
8
>>>>SELECT IIF(alias.gender = "M", "Male", "Female") AS GenderText FROM Customers
>>>that works...thanks...:)
>>
>>IIF won't work in SQL Server though, if that applies. Your best bet, to make it scaleable or simpler in VFP would be to have a table like this:
>
gender.dbf
>code	gender
>--------------
>m	Male
>f	Female
>>and then build your SQL like this:
>>
>>SELECT gender.gender FROM alias LEFT JOIN gender ON alias.gender = gender.code
>
>Ooh, nice save, Mike. Something to think about next time....

Note the subtle insertion of LEFT before the join, so you may get a few people with NULL gender... besides, they should be entitled to delaying the decision until they grow up :)

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform