Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Posts
    73

    Unanswered: iff statement with an or

    this may be a stupid question, but is there a way to do an iff statement in sql with an or?

    This is what i'm trying to get in ONE iff statement:

    IF {table.x} = "NA" or {table.y} = "B" THEN
    formula={table.z}
    ELSE
    formula={table.z} & {table.x}
    END IF
    Last edited by tkat11; 06-02-04 at 12:13. Reason: accidentally posted

  2. #2
    Join Date
    Jun 2004
    Location
    NYC Area
    Posts
    24
    Try using the CASE..

    CASE WHEN xxxx THEN xxxx ELSE xxxx END
    or nested...
    CASE WHEN xxx THEN xxx ELSE CASE WHEN yyy THEN yyy ELSE yyy END END

    Should work

  3. #3
    Join Date
    Oct 2003
    Posts
    73
    thx for the reply Hammett.
    the case statement will only work in a passthrough statement right? I thought I read that Access does not support Case statements on its local tables. Therefore, it should work on linked Sequel tables...

    Any other ideas?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    iif(table.x = 'NA' or table.y = 'B'
      , table.z
      , table.z & table.x) as formula
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Oct 2003
    Posts
    73
    Rudy to the rescue again.

    you know, i was betting that that was going to be the answer, but I hadn't had time to test it. Plus, I couldn't find anything else online with an 'or' in the iif statement.

    thx for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •