select top 8 id,class,title,titlecolor,excerpt,annex from t_ar where check=1 and (class like '001030%' or class like '%;001030%') order by top desc,time desc如何优化?
select top 8 id,class,title,titlecolor,excerpt,annex from t_ar where check=1 and (class like '001030%' or class like '%;001030%') order by top desc,time desc如何优化?
where check=1 and (left(class,6) = '001030' or class like '%;001030%')
order by top desc,time desc
from t_ar
where [check]=1
and (class like '001030%' or class like '%;001030%')
order by [top] desc,[time] desc几个关键字帮你框一下,遇到 '%内容%'这样的查询,没什么优化的空间了,因为相关列引用不了索引.
where check=1 and (left(class,6) = '001030' or class like '%;001030%')
order by [top] desc,time desc
like 可以用charindex试试
请问:第二个Top desc 是什么意思呀?我不太明白。