当前位置: 代码迷 >> Sql Server >> 【mysql】把查询的结果转为字符串运算
  详细解决方案

【mysql】把查询的结果转为字符串运算

热度:58   发布时间:2016-04-24 20:03:29.0
【mysql求助】把查询的结果转为字符串运算
select 100 - NULL   结果为NULL
select 100 -‘NULL’结果为100
select 100 - 50     结果为50
select 100 - ‘50’ 结果为50
求助解决第一个例子。我想把查询出来的NULL转换成‘NULL’怎么办?
MYSQL

------解决方案--------------------
试试这样能行不:

select 100 - case when NULL is null then 'NULL' else null end   

------解决方案--------------------
select if(100 - NULL is null ,'null',100-null)
------解决方案--------------------
select a+b
from (
select sum(a)a ,0 b from a  where 1
union all 
select 0,-1*sum(b) from b)a
------解决方案--------------------
  相关解决方案