Nested case in Mysql
I need to write a SQL statement
- if TC is g开发者_StackOverflowreater than 1 return 500
- if TC is greater than .5 return 200
- if TC is greater than .25 return 100
- if TC is less than .25 return 50.
I know it's a nested case, using MySQL
EDIT:
If table two has columns Id
, TC
, how do I use above to update the TC value.
select case when tc > 1 then 500
when tc > .5 then 200
when tc > .25 then 100
else 50
end
...
EDIT: Based on comments from OP
update YourTable
set tc = case when tc > 1 then 500
when tc > .5 then 200
when tc > .25 then 100
else 50
end
精彩评论