How to get more than one filed in Case Statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashokakr
    New Member
    • Jul 2007
    • 7

    How to get more than one filed in Case Statement

    Hi All,

    I am new to mysql, can any one help me to solve this problem,

    i have a query, based on the condition i have to get two fields from the same table,
    how to solve this problem,


    select
    (case
    when hor_val>0 then hor_desc,hor_va l
    end) from temp

    hor_val is a integer filed, hor_desc is a varchar field,

    based on the har_val i have to get hor_desc and hor_val as output.

    please give the solution, as earlier as possible.
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Originally posted by ashokakr
    please give the solution, as earlier as possible.
    Here all the experts are volunteers. They reply in their free time.

    Try the following code
    [CODE=mysql]SELECT CASE WHEN hor_val>0 THEN hor_desc ELSE hor_val END
    FROM temp[/CODE]

    Comment

    • ashokakr
      New Member
      • Jul 2007
      • 7

      #3
      hi,

      i tried ur code but i need to get the two fields if the value is greater the zero, not the single field.

      so please solve the problems quickly

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        please give the solution, as earlier as possible
        so please solve the problems quickly
        I really don't like remarks like these, looks more like demands.
        And, as the previous poster already said, this forum is supported by volunteers helping out when and where they can and in their own time. Demanding things does not really help to get them enthusiastic for your problem.

        Ronald

        Comment

        Working...