Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread SQL syntax
Tue, Mar 23 2010 11:15 PMPermanent Link

Robert Kaplan

Is there a way to have something like

SELECT
IF (CONDITION 3 ELSE 4) MYCODE
FROM TABLEA
WHERE MYCODE <> SOMEFIELD

IOW once I create mycode, to be able to use it just like any other column,
even something like

SELECT
IF (CONDITION 3 ELSE 4) MYCODE
FROM TABLEA
JOIN TABLEB ON TABLEB.FIELD = MYCODE

I suspect the answer is no, but who knows.

Robert

Wed, Mar 24 2010 5:59 AMPermanent Link

John Hay

Rober

> IOW once I create mycode, to be able to use it just like any other column,
> even something like
>
> SELECT
> IF (CONDITION 3 ELSE 4) MYCODE
> FROM TABLEA
> JOIN TABLEB ON TABLEB.FIELD = MYCODE

The following should work

SELECT
IF (CONDITION 3 ELSE 4) MYCODE
FROM TABLEA
JOIN TABLEB ON TABLEB.FIELD = IF (CONDITION 3 ELSE 4)

John

Wed, Mar 24 2010 6:39 AMPermanent Link

John Hay

Robert

The actual syntax for DBIsam is

SELECT
IF (CONDITION THEN 3 ELSE 4) MYCODE
FROM TABLEA
JOIN TABLEB ON TABLEB.FIELD = IF (CONDITION THEN 3 ELSE 4)

John

Wed, Mar 24 2010 7:28 AMPermanent Link

Robert Kaplan


"John Hay" <j.haywithoutdot@crbsolutionsremoveallthis.co.uk> wrote in
message news:350500BE-BB01-4714-B65A-E74072501779@news.elevatesoft.com...
> JOIN TABLEB ON TABLEB.FIELD = IF (CONDITION THEN 3 ELSE 4)
>

Thanks John, that's what I've always done, I was looking for a way to
eliminate the restating of the IF clause.

Robert

Image