Results 1 to 5 of 5

Thread: If construct

  1. #1
    Join Date
    Feb 2009
    Posts
    4

    Unanswered: If construct

    Hi, in the following mysql select statement i use an if construct to get a sign changed in the recordset.

    SELECT a.fieldone, a.fieldtwo, if(a.fieldone="x",a.fieldthree,-a.fieldthree) as myfield FROM mytable a

    I would like to have the same result on an informix db. Is it possible? If so, what is the If syntax?

    Many thanks in advance.

    //andrea

  2. #2
    Join Date
    Jul 2009
    Posts
    37
    decode() is functionally similar.

    Manual and examples here - IBM Informix Dynamic Server v10 Information Center

    SELECT a.fieldone, a.fieldtwo, decode(a.fieldone,"x",a.fieldthree,-a.fieldthree) as myfield
    FROM mytable a

  3. #3
    Join Date
    Feb 2009
    Posts
    4
    thanks a lot, bigcalm

  4. #4
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Or CASE. Is more useful then decode() when an unknown kind of different cases have to be covered by ELSE.
    Code:
    SELECT  CASE fieldone
    	WHEN 'x' THEN fieldthree
    	WHEN 'y' THEN ...
    	ELSE -fieldthree
    	END myfield
    FROM mytable;
    Regards,
    Hans

  5. #5
    Join Date
    Jul 2009
    Posts
    1
    Dear players, do you need Gold for WOW? We provide you withWOW Gold, cheap WOW Gold, including
    World of Warcraft EU Gold aWorld of Warcraft US Gold . Also we supply Metin2 Yang and Metin2 Gold to Metin2 players. Besides we also offer WOW Level Power Leveling.

Posting Permissions

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