首页 新闻 会员 周边 捐助

Like 效率问题

0
[待解决问题]
DECLARE @SapCount INT=0 
        DECLARE @AppNum INT =0
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox40*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox42*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox32*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox34*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox36*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox38*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox30*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox28*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox26*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum
        SELECT @AppNum=count(prn.intApplyID)
             FROM printReportName AS prn WHERE prn.AneZqspecial like '%checkBox24*True%' AND ID=@OpeId
        SET  @SapCount=@SapCount+@AppNum

当需要字段某个值是否为true 多重like怎么优化

字符串如下

checkBox72*False|checkBox91*False|checkBox92*False|checkBox51*False|checkBox52*False|checkBox35*False|checkBox36*False|
checkBox113*False|checkBox114*False|checkBox150*False|checkBox133*False|checkBox134*False|checkBox73*False|checkBox74*False|
checkBox93*False|checkBox94*False|checkBox53*False|checkBox54*False|checkBox37*False|checkBox38*False|checkBox115*False|

路过相遇错过的主页 路过相遇错过 | 初学一级 | 园豆:6
提问于:2015-05-18 12:49
< >
分享
所有回答(2)
0

ID与AneZqspecial字段都建索引了吗?

dudu | 园豆:30939 (高人七级) | 2015-05-18 13:23
0

看看能不能用到分组求和。

清海扬波 | 园豆:825 (小虾三级) | 2015-05-20 14:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册