image=case when(not Cover is null) then ' <img src=ReadBookCover.aspx?id='+cast(id as varchar(10))+' Border=1 width=80 height=120>' else ' <img src=img/pic.jpg border=1 width=80 height=120>' end 表示:如果Cover字段不为空的话,就返回字符串' <img src=ReadBookCover.aspx?id='+cast(id as varchar(10))+' Border=1 width=80 height=120>',并且命名为image(可以用iamge作为字段名取出这个字符串),其它情况返回字符串' <img src=img/pic.jpg border=1 width=80 height=120>'(pic.jpg应该是站点下的一个默认的图片文件)。如果把这个SQL语句自整理成规范的格式就清楚多了:strsql=
"select id,name,discount,author,price,type ,image=
case
when(not Cover is null)
then ' <img src=ReadBookCover.aspx?id='+cast(id as varchar
(10))+' Border=1 width=80 height=120>'
else ' <img src=img/pic.jpg border=1 width=80 height=120>'
end
from book
where type="+BookTypeId;
"select id,name,discount,author,price,type ,image=
case
when(not Cover is null)
then ' <img src=ReadBookCover.aspx?id='+cast(id as varchar
(10))+' Border=1 width=80 height=120>'
else ' <img src=img/pic.jpg border=1 width=80 height=120>'
end
from book
where type="+BookTypeId;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货