pwinters
Programmer
- Sep 12, 2002
- 34
Is it possible to have an if else statement in a SQL Update statement?
I want to...
Update Table1
If (field1 != 0)
set field1 = variable
,field2 = variable2
,field3 = variable3
else
field4 = variable4
etc..
What I'm really trying to do is allow null values to be entered in my form. Currently, when a user leaves a field blank, I get a "syntax error in Update statement". When the fields are all filled in, it works fine.
Can this be done? Or would there be a better way to do something like this?
Any help would be appreciated.
Thanks.
I want to...
Update Table1
If (field1 != 0)
set field1 = variable
,field2 = variable2
,field3 = variable3
else
field4 = variable4
etc..
What I'm really trying to do is allow null values to be entered in my form. Currently, when a user leaves a field blank, I get a "syntax error in Update statement". When the fields are all filled in, it works fine.
Can this be done? Or would there be a better way to do something like this?
Any help would be appreciated.
Thanks.