Home » SQL & PL/SQL » SQL & PL/SQL » sql question
sql question [message #347029] Wed, 10 September 2008 08:23 Go to next message
rakeshforum
Messages: 5
Registered: September 2008
Location: india
Junior Member
hi everyone,

there is table called emp, in emp table there is column named
gender

gender
------
m
f
m
f
so on

with using single update statemant , update this column like whereever
m is there change it to f
f is there change it to f

i.e
above column became
gender
------
f
m
f
m

regards,
rakesh
Re: sql question [message #347030 is a reply to message #347029] Wed, 10 September 2008 08:24 Go to previous messageGo to next message
Michel Cadot
Messages: 64133
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
From your previous topic with the same meaningless and useless title:
Michel Cadot wrote on Wed, 10 September 2008 14:43
Also please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel

I add:
- Post what you already tried
- Post a test case: create table and insert statements along with the result you want with these data.

[Updated on: Wed, 10 September 2008 08:25]

Report message to a moderator

Re: sql question [message #347047 is a reply to message #347029] Wed, 10 September 2008 09:08 Go to previous messageGo to next message
developer69
Messages: 6
Registered: September 2008
Junior Member
This might work:

update emp set gender = decode(gender,'M','F','F','M',Null);


You can get more details on "Decode" function here:
http://www.techonthenet.com/oracle/functions/decode.php

Thanks

[Updated on: Wed, 10 September 2008 09:11]

Report message to a moderator

Re: sql question [message #347048 is a reply to message #347047] Wed, 10 September 2008 09:14 Go to previous messageGo to next message
Michel Cadot
Messages: 64133
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
@developer69

Don't put solution only hint or clue as requested in OraFAQ Forum Guide, "Responding to Posts" section:
Quote:
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.


Regards
Michel
Re: sql question [message #347050 is a reply to message #347047] Wed, 10 September 2008 09:21 Go to previous message
developer69
Messages: 6
Registered: September 2008
Junior Member
My apologies am new here, Shall do that from now on.

Thanks
Sam
Previous Topic: SQL question
Next Topic: move segments from one tablespace to other tablespace
Goto Forum:
  


Current Time: Thu Dec 08 04:03:26 CST 2016

Total time taken to generate the page: 0.16735 seconds