Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

select case syntax in foxpro

select case syntax in foxpro

It's been a while since I used foxpro. I need the syntax for doing case statements in a select. Ie. in sql server it's

select case when state='al' then 'alabama' end
from table

so what is the syntax dto do this in foxpro, or can you not use case in a select?


RE: select case syntax in foxpro

Hi Tim,

I don't think there's a CASE clause in SELECT SQL.


SELECT <fieldlist> ;
FROM <tablename> ;
WHERE UPPER(LEFT(state, 2)) = "AL"



RE: select case syntax in foxpro


Yes, there isn't a CASE clause in SELECT SQL that I am aware of, but you could use the IIF() function.


SELECT IIF(state="AL", "Alabama", ;
       IIF(state="CA", "California", ;
       "some other state")) ;
  FROM yourtable

RE: select case syntax in foxpro

Actually, VFP 9 adds the ICASE() function that's analogous to IIF(). To borrow TheRambler's example:


SELECT ICASE(state="AL","Alabama", ;
             state="CA", "California", ;
             "some other state") ;
  FROM YourTable


RE: select case syntax in foxpro

Thanks Tamar, I didn't know that.  Now I see it is possible to pass up to 100 pairs of parameters for ICASE().

RE: select case syntax in foxpro

TamarGranor, I gave a star because I read through all the VFP 9 new features and overlooked ICASE() or more likely promptly forgot it.

I have a tough problem over at Thread1253-1013978 that so far no one's commented on.  It's in a small web-related VFP forum. It deals with Web Services, VFP dll as IUSR, to VFP exe as IWAM, which then crashes with a probably rights issue when trying to APPEND GENERAL for MsGRAPH to set up a pie chart for inclusion in a report. Any help is appreciated - it's a real stumper!

RE: select case syntax in foxpro


I have a tough problem over at Thread1253-1013978 that so far no one's commented on.

I know that it can be annoying when you post a question and no-one answers. But it's not a good idea just to repeat the question in another thread.

If there are any forum members who can help you with web services, etc., they are unlikely to see your question buried in a thread about the CASE construct. Also, for the benefit of people searching for information in the future, it is better for each subject to have its own thread with a title that indicates the nature of the discussion.


Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (
Crystal Reports (

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close