Using IF in a SELECT statement?

  • quote:


    I can use CASE, but then I'll need to do CASE WHEN bill_method = 'CC' 4 times to display CC_Name, CC_Type, CC_Number, CC_Exp. If I can use IF, that will be more efficient, right


    SELECT account_id, bill_contact, bill_address, CC_Name, CC_Number, CC_TYPE, CC_Exp

    FROM account WHERE bill_method = 'CC'

    union all

    SELECT account_id, bill_contact, bill_address, null, null, null, null

    FROM account WHERE bill_method <> 'CC'

    I'm not sure if it is more efficient, but it does eleminate the 4 case statements.

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply