存进去的时候没做过索引和专门的数据库设计,那只能用like的方法查

解决方案 »

  1.   

    select Tag,Title,Synopsis from New where 1=1 and( Tag like '%天气%' or Title like '%天气%' or synopsis like '%天气%'); ---------------
    1. like '%天气%' 用不到索引 不过2005的可以2 建议你改成
    select Tag,Title,Synopsis from New where 1=1 and Tag like '%天气%' 
    union all
    select Tag,Title,Synopsis from New where 1=1 and Title like '%天气%' 
    union all
    select Tag,Title,Synopsis from New where 1=1  and synopsis like '%天气%'
      

  2.   

    这种查询本来效率就不高.
    --try
    select Tag,Title,Synopsis from New where charindex('天气',Tag)+ charindex('天气',Title)+charindex('天气',synopsis)>0
      

  3.   


    --显示加上排序:
    select * from New where 
    charindex('天气',tag)>0 or charindex('天气',title)>0 or charindex('天气',synopsis)>0
    order by case when charindex('天气',tag)>0 then 0
    when charindex('天气',title)>0 then 1
    when charindex('天气',synopsis)>0 then 2 end