日期:2014-05-17  浏览次数:20422 次

【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
------解决方案--------------------