这个sql语句怎样改了下,能提高点速度?现在我用这个sql几千条数据,分页比较慢。
select * from moonjxcmx where buyersId like '%"+ViewState["seeBuyersId"]+"%' and buyersMs like '%"+ViewState["seeBuyersName"]+"%' and goodsId like '%"+ViewState["seeGoodsId"]+"%' and goodsSpell like '%"+ViewState["seeGoodsName"]+"%' and onlyId like '%"+seeOnlyId.Text+"%' order by "+str+" "+ViewState["Direction"].ToString()
select * from moonjxcmx where buyersId like '%"+ViewState["seeBuyersId"]+"%' and buyersMs like '%"+ViewState["seeBuyersName"]+"%' and goodsId like '%"+ViewState["seeGoodsId"]+"%' and goodsSpell like '%"+ViewState["seeGoodsName"]+"%' and onlyId like '%"+seeOnlyId.Text+"%' order by "+str+" "+ViewState["Direction"].ToString()
数值类型全部换成=
2.用charindex代替Like~
看你情况吧,总之like少用或者你用 charindex('"+ViewState["seeBuyersId"]+"',buyersId)>0 代替like试试
2.用charindex代替Like~3.要不用存储过程?
2.少用like,确定值的用=,固定值的界面就让选,然后用=
3.改用存储过程