Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-05-31 : 04:37:23
|
| If data is cat or dog from animal column, then output for that column is Mammal.Can I do that?AnimalMammal |
|
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-05-31 : 05:27:53
|
| update tab_name set animal = 'mamml'where animal in ('cat','dog') |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-05-31 : 05:42:31
|
| Not update.What I meant is:Select animal from tableAwhere animal in ('dog','cat')Animal Ownerdog Marrycat Janesnake BrianWhat I want is to be like this:Animal OwnerMammal MarryMammal Janesnake BrianCan I do that? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-05-31 : 05:46:41
|
selectcasewhen animal in ('dog','cat') then 'Mammal'else animalend as animal,ownerfrom tableA No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-05-31 : 06:54:07
|
| owner is your second column or both are same ? |
 |
|
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-05-31 : 07:05:12
|
| if u just want to replace it then usethis :select REPLACE(animal,'dog','mammal') from tab_name select REPLACE(animal ,'cat','mammal') from tab_name |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-05-31 : 23:26:56
|
| owner is second column |
 |
|
|
mani_12345
Starting Member
35 Posts |
Posted - 2012-05-31 : 23:29:41
|
| see my last post it will solve the problem whether u have single column or differnt column.... |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-06-01 : 02:21:22
|
quote: Originally posted by peace owner is second column
Please see my given solution. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|