SQL中的判断
select top 6
图书信息_id,
现价,
原价,
图书名称,
简介=' '+SUBSTRING(简介,0,150)+'......',
封面图=
case when(not 封面图 is null)
then ' <img src=ReadBookCover.aspx?id='+cast(图书信息_id as varchar(10))+' Border=1 width=70 height=100>'
else ' <img src=images/pic.jpg border=1 width=70 height=100>'
end
from 图书信息
order by 购进日期 DESC";
语法:
CASE expr WHEN comparison_expr1 THEN return_expr1
[WHEN comparison_expr2 THEN return_expr2
WHEN comparison_exprn THEN return_exprn
ELSE else_expr]
END
select case when(STATUS = 0)
then '新创建'
when(STATUS = 1) then '发布'
else '失效'
end as STATUSs from Auction
select
count(
case when(description is null )
then ' '
else
to_char(substr(description,0,1000))
end
)
from producttext
CLOB 字段是 null
给CLOB字段赋空值 是 Empty_CLOB()
截取读取处理 如上面的
图书信息_id,
现价,
原价,
图书名称,
简介=' '+SUBSTRING(简介,0,150)+'......',
封面图=
case when(not 封面图 is null)
then ' <img src=ReadBookCover.aspx?id='+cast(图书信息_id as varchar(10))+' Border=1 width=70 height=100>'
else ' <img src=images/pic.jpg border=1 width=70 height=100>'
end
from 图书信息
order by 购进日期 DESC";
语法:
CASE expr WHEN comparison_expr1 THEN return_expr1
[WHEN comparison_expr2 THEN return_expr2
WHEN comparison_exprn THEN return_exprn
ELSE else_expr]
END
select case when(STATUS = 0)
then '新创建'
when(STATUS = 1) then '发布'
else '失效'
end as STATUSs from Auction
select
count(
case when(description is null )
then ' '
else
to_char(substr(description,0,1000))
end
)
from producttext
CLOB 字段是 null
给CLOB字段赋空值 是 Empty_CLOB()
截取读取处理 如上面的
浙公网安备 33010602011771号