Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-03-07 : 08:18:16
|
Anand writes "Hi all please help me in my query one recruiter ask me how to do this. here it is what they did ask me:-------there is one table in that table two columns name and gender and the things is that suppose the table is like thatName GenderKen Mkate FLucy FBrian M so please what we have to do write only one single query which we will select all the male from the databse and update them to female and all female to Mail but this should be only in one single query.Not a two query at all okplease help i did use select case but no luck!!!:( please reply to me onephpguy@yahoo.comThanks to whole SQL team." |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-03-07 : 08:18:55
|
Before posting any answers, please refer to this thread:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62702 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-07 : 08:25:16
|
What have you already tried ? ----------------------------------'KH' |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2006-03-07 : 08:26:33
|
Before I can provide an answer to this question, I need to know which washing powder Lucy uses.-------Moo. :) |
|
|
twhelan1
Yak Posting Veteran
71 Posts |
Posted - 2006-03-07 : 09:29:26
|
Must have been a job interview with a Swiss company? Nevermind... bad joke.~Travis |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-03-07 : 11:26:44
|
This should do the job.update Mytableset Gender = case when name in ('Ken','Brian') then 'F' when name in ('Kate','Lucy') then 'Mail' else Gender end CODO ERGO SUM |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-03-07 : 11:41:04
|
Perhaps he works for a doctor that performs sex changes? |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2006-03-07 : 12:37:59
|
quote: Originally posted by Michael Valentine Jones This should do the job.update Mytableset Gender = case when name in ('Ken','Brian') then 'F' when name in ('Kate','Lucy') then 'Mail' else Gender end CODO ERGO SUM
I really hope someone submits this in an interview.===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-03-07 : 13:58:58
|
quote: Originally posted by graz...I really hope someone submits this in an interview...
I believe it meets all stated requirements.CODO ERGO SUM |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-10 : 00:45:35
|
This can be fun!update Mytableset Gender = case when len(name) % 2 = 0 then 'M' else 'F' end Peter LarssonHelsingborg, Sweden |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-11-10 : 10:51:44
|
MadhivananFailing to plan is Planning to fail |
|
|
General Anders
Starting Member
3 Posts |
Posted - 2007-07-23 : 19:40:53
|
It sounds like the professor isn't asking you to modify the database but just to return the inverse of M/F? If the datatypes are set properly (restricts to M or F) could we just use the NOT function?select name, NOT gender |
|
|
|