(ASP2.0,C#)假如我在文本框中输入了四个关键字(关键字个数并不固定),如何让数据库表中一个字段的内容匹配四个关键字的结果最先显示,然后依次显示匹配其中三个关键字、两个关键字、一个关键字的结果?(查找结果绑定在DataList中)哪位高人指点一下啊?

解决方案 »

  1.   

    select * from T where col like '%con4%'
    union
    select * from T where col like '%con3%'
    union
    select * from T where col like '%con2%'
    union
    select * from T where col like '%con1%'con4,3,2,1为你匹配的关键字 查询出来之后绑定到你的DataList中就可以
      

  2.   

    每个关键字都有自己的Rank,根据Rank确定那个最匹配
      

  3.   

    我用的是union 会去掉重复数据  union all才会关连所有的匹配