一般情况下select语句都能被if 语句代替,但是if语句要比select语句执行效率差很多
能写select尽量写select
select case fenlei
case "xiaoxue"
fenlei1 = "小学"
txtstr = replacestr(txtstr,"xuanzhong","#小学#")
case "zhongxue"
fenlei1 = "中学"
txtstr = replacestr(txtstr,"xuanzhong","#中学#")
case "daxue"
fenlei1 = "大学"
txtstr = replacestr(txtstr,"xuanzhong","#大学#")
case "zhuanjia"
fenlei1 = "专家"
txtstr = replacestr(txtstr,"xuanzhong","#专家#")
case "zhijiao"
fenlei1 = "职教"
txtstr = replacestr(txtstr,"xuanzhong","#职教#")
case "jiangshi"
fenlei1 = "讲师"
txtstr = replacestr(txtstr,"xuanzhong","#讲师#")
end select

SQL Case 语句应用实例
本文通过一个具体的案例展示了如何使用 SQL 中的 case 语句来根据不同的分类替换字符串,这种方法相较于 if 语句拥有更好的执行效率。
1086

被折叠的 条评论
为什么被折叠?



