DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: update query

  1. #1
    Join Date
    Aug 2007
    Posts
    18

    Question update query

    i have created a table called employ, that consists a column called gender, in which i have stored with male and female.
    i want to convert male to female and female to male.
    plz help me out of ths query


    Example:

    table name : employ
    column name : gender

    gender
    ------
    male
    female
    male
    female
    female

    i want to convert male to female and female to male

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    You can use either extreme surgery or the code below...

    Code:
    update employ
    set    gender = decode(gender,'male','female','female','male','???') 
    ;
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Aug 2007
    Posts
    3
    u can update like this..............



    Update employ set gender =
    case when gender in(‘female')
    then ‘male’
    when gender in(‘male’)
    then ‘female’
    else gender
    end

Posting Permissions

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


Click Here to Expand Forum to Full Width