|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
conditionally select a field depending on another field value
I want in my query to select a different field in case another one is null. in mysql i'd do it like this:
select a ,if(b is null, c, b) ,d from alphabet how can this be done in sql server? thanks |
|
#2
|
||||
|
||||
|
case when b is null then c else b end
easy, wasn't it or, in the special situation where you're testing for null and want to accept the value if it isn't, you can also say coalesce(b,c) ![]() |
|
#3
|
|||
|
|||
|
Thanks
![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > conditionally select a field depending on another field value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|