Reputation: 621
in my sql query - one line as listen below returns me a varchar - I need to use a case statement (i think case is the way to go) so that when AC.Type_Name = 'None' Then I need to store '' as TypeName, not the word none. Anyone know the most simple way to do this? Thank you.
AC.Type_Name As TypeName,
this is used in part of a stored procedure - it isn't stored to a table. It is for use with a asp.net application. I could store the results to a temporary table, then use update as said below by redfilter, then return the temp table but I was looking for the quickest way possible
Upvotes: 0
Views: 79
Reputation: 660
I am assuming that your code reference above refers to a field in the select clause of a stored procedure. If that's the case, you should be able to modify it as follows:
(case when AC.Type_Name = 'None' then '' else AC.Type_Name end) as TypeName
This statement will return a column called TypeName that will contain the value of AC.Type_Name unless the value of AC.Type_Name is 'None', in which case it will return it as an empty string.
Upvotes: 1
Reputation: 12877
you should be able to use the 'if()' function.
SELECT IF(AC.Type_Name = 'None', '', AC.TypeName) FROM ....
Upvotes: 0
Reputation: 171401
update MyTable
set Type_Name = case when @input = 'None' then '' else @input end
where ...
Upvotes: 1