"如果A字段包含这个词就排在最前面,如果B字段包含这个词就排在中间,如果C字段包含这个词就排在最后面。"什么意思嘛?

解决方案 »

  1.   

    select A from Table where A like '%你要查的内容%' union
    select B from Table where B like '%你要查的内容%' union
    select C from Table where C like '%你要查的内容%'
      

  2.   

    半精确查找:
    select A , B , C from 
       (Select A , B , C , O = case 
                                  when CharIndex('Word' , A) > 0 then 1
                                  when CharIndex('Word' , B) > 0 then 2
                                  when CharIndex('Word' , C) > 0 then 3
                            end
              from TableName where  A like 'Word' or B like 'Word' or C like 'Word') TX order by O
      

  3.   

    select A , B , C from
     (
        select A , B , C , O = 1 from TableName where A like '%xxx%' union
        select A , B , C , O = 2 from TableName where B like '%xxx%' and A not like '%xxx%' union
        select A , B , C , O = 3 from TableName where C like '%xxx%' and A not like '%xxx%' and B not like '%xxx%'
      ) TX order by O
      

  4.   

    非常谢谢zhq2000网友,我已经按您的指点做了实验,完全符合我的要求。可否留下您的邮件,以后向您请教?我的邮件是[email protected]
      

  5.   

    ZHQ2000的理解力果然非凡
    CBUILDER兄说声感谢,连分都忘了给呢?  :)
      

  6.   

    非常不好意思,我不知道如何给分。可否指教?
    另外,zhq2000的SQL语句中,不能选择text、ntext,image的列,而我恰恰需要选择这样的列,我做了试验,发现是union的问题,请指教!
      

  7.   

    非常不好意思,我不知道如何给分。可否指教?
    另外,zhq2000的SQL语句中,不能选择text、ntext,image的列,而我恰恰需要选择这样的列,我做了试验,发现是union的问题,请指教!