本帖最后由 viphk 于 2010-10-15 12:55:17 编辑

解决方案 »

  1.   

    select *  from 表 where 关键字 like '%15%'  查找关键字含有带有15的所有结果集
      

  2.   

    select * from merchandise where title like '%15日%' and (content like '%北京市%' or content like '%化妆品%' or content like '%香水%')
      

  3.   

    select * from 表 where 日期 like '%15%' and 关键字 like '%+"包含的关键字"+%'
      

  4.   

    拼sql:
            string[] gj = TextBox1.Text.Split(',');
            string whe = " where (";
            for (int i = 0; i < gj.Length; i++)
            {
                whe += "( 内容字段 like '%" + gj[i] + "%') or ";
            }
            whe = whe.Substring(0, whe.Length - 3)+") ";
            string sql = "select * from 表 " + whe+ " and (日期字段 between ... and ... )";
      

  5.   


    LZ看到这个还没有思路么、把输入的关键字挨个读取出来;
    若是不知道关键字的个数可将关键字放到数组中、然后根据关键字的个数控制content like '%关键字%'的数量
      

  6.   

    接9楼:
    TextBox1.Text="北京市,香水,化妆品";
      

  7.   

    我的那个不行吗????????
    页面代码:
    string sql="select * from biaoming where 1=1 and ";
    if(txtDateTime.text.trim().leng>0)
    {
       sql+="'%"+this.txtDataTime.text+"%'";
    }
    if(this.txtContent.text.trim().leng>0)
    {
       int index=this.txtContent.text.indexof(',');
       string[] strContent=null;
       if(index>0)
       {
          strContent=this.txtContent.text.split(new char[]{','},StringSplitOptions.None);
          for(int i=0;i<strContent.length;i++)
          {
             sql+=" '%"+strContent[i]+"%' ";
          }
       }else
       {
          sql+=" '%"+this.txtContent.text+"%' ";
       }
    }